Browse Source

添加供应商跟进功能,包括跟进按钮、跟进信息模态框和后端API

Boss3
Default User 1 month ago
parent
commit
068330797e
  1. 31
      Reject.js
  2. 140
      SupplierReview.html

31
Reject.js

@ -1811,7 +1811,7 @@ app.get('/api/suppliers', async (req, res) => {
// 查询供应商列表,按创建时间倒序排序,确保最新创建的在前面 // 查询供应商列表,按创建时间倒序排序,确保最新创建的在前面
const [suppliers] = await connection.query( const [suppliers] = await connection.query(
`SELECT userId, phoneNumber, province, city, district, detailedaddress, company, collaborationid, cooperation, businesslicenseurl, proofurl, brandurl, partnerstatus, reasonforfailure, reject_reason, terminate_reason, audit_time, created_at, liaison `SELECT userId, phoneNumber, province, city, district, detailedaddress, company, collaborationid, cooperation, businesslicenseurl, proofurl, brandurl, partnerstatus, reasonforfailure, reject_reason, terminate_reason, audit_time, created_at, liaison, seller_followup
FROM users${whereClause} FROM users${whereClause}
ORDER BY created_at DESC LIMIT ? OFFSET ?`, ORDER BY created_at DESC LIMIT ? OFFSET ?`,
params params
@ -1832,6 +1832,35 @@ app.get('/api/suppliers', async (req, res) => {
} }
}); });
// 供应商跟进信息API - /api/suppliers/:id/followup
console.log('正在注册供应商跟进信息API路由: /api/suppliers/:id/followup');
app.post('/api/suppliers/:id/followup', async (req, res) => {
console.log('收到供应商跟进信息更新请求:', req.params.id);
try {
const connection = await pool.getConnection();
const supplierId = req.params.id;
const { content } = req.body;
if (!content) {
connection.release();
return sendResponse(res, false, null, '跟进信息不能为空');
}
// 更新供应商跟进信息
await connection.query(
'UPDATE users SET seller_followup = ? WHERE userId = ?',
[content, supplierId]
);
connection.release();
sendResponse(res, true, null, '跟进信息保存成功');
} catch (error) {
console.error('更新供应商跟进信息失败:', error.message);
console.error('错误详情:', error);
sendResponse(res, false, null, '更新供应商跟进信息失败');
}
});
// 管理员统计 - 获取货源创建统计数据 // 管理员统计 - 获取货源创建统计数据
app.get('/api/admin/stats/supplies', async (req, res) => { app.get('/api/admin/stats/supplies', async (req, res) => {
try { try {

140
SupplierReview.html

@ -1039,6 +1039,23 @@
</div> </div>
</div> </div>
<!-- 跟进信息弹窗 -->
<div id="followupModal" class="modal">
<div class="modal-content">
<div class="modal-header">供应商跟进</div>
<div class="modal-body">
<textarea id="followupContent" placeholder="请输入跟进信息..." maxlength="1000" style="height: 150px;"></textarea>
<div style="text-align: right; margin-top: 5px; font-size: 12px; color: #999;">
<span id="followupCharCount">0</span>/1000
</div>
</div>
<div class="modal-footer">
<button id="cancelFollowupBtn" class="btn btn-default">取消</button>
<button id="confirmFollowupBtn" class="btn btn-primary">确认保存</button>
</div>
</div>
</div>
<script> <script>
// 登录检查 // 登录检查
function checkLogin() { function checkLogin() {
@ -1670,9 +1687,20 @@
</div> </div>
` : ''} ` : ''}
<!-- 跟进信息 -->
${supplier.seller_followup ? `
<div class="supply-followup" style="margin-top: 15px; padding: 10px; background-color: #f0f9ff; border: 1px solid #bae7ff; border-radius: 4px;">
<div class="label" style="font-size: 12px; color: #1890ff; margin-bottom: 5px;">跟进信息:</div>
<div class="followup-content" style="font-size: 14px; color: #333;">${supplier.seller_followup}</div>
</div>
` : ''}
<!-- 操作按钮 --> <!-- 操作按钮 -->
<div class="action-buttons"> <div class="action-buttons">
${canReview ? ` ${canReview ? `
<button class="btn btn-default" data-id="${id}" onclick="showFollowupModal('${id}')">
跟进
</button>
<button class="btn btn-primary" data-id="${id}" onclick="showSupplierApproveModal('${id}')"> <button class="btn btn-primary" data-id="${id}" onclick="showSupplierApproveModal('${id}')">
通过 通过
</button> </button>
@ -1680,6 +1708,9 @@
拒绝 拒绝
</button> </button>
` : canTerminate ? ` ` : canTerminate ? `
<button class="btn btn-default" data-id="${id}" onclick="showFollowupModal('${id}')">
跟进
</button>
<button class="btn btn-danger" data-id="${id}" onclick="showTerminateModal('${id}')"> <button class="btn btn-danger" data-id="${id}" onclick="showTerminateModal('${id}')">
终止合作 终止合作
</button> </button>
@ -1687,6 +1718,9 @@
审核时间:${formatTime(auditTime)} 审核时间:${formatTime(auditTime)}
</div> </div>
` : canCooperate ? ` ` : canCooperate ? `
<button class="btn btn-default" data-id="${id}" onclick="showFollowupModal('${id}')">
跟进
</button>
<button class="btn btn-primary" data-id="${id}" onclick="confirmSupplierToCooperation('${id}')"> <button class="btn btn-primary" data-id="${id}" onclick="confirmSupplierToCooperation('${id}')">
开始合作 开始合作
</button> </button>
@ -1694,6 +1728,9 @@
审核时间:${formatTime(auditTime)} 审核时间:${formatTime(auditTime)}
</div> </div>
` : ` ` : `
<button class="btn btn-default" data-id="${id}" onclick="showFollowupModal('${id}')">
跟进
</button>
<div class="audit-time"> <div class="audit-time">
审核时间:${formatTime(auditTime)} 审核时间:${formatTime(auditTime)}
</div> </div>
@ -1891,6 +1928,66 @@
} }
} }
// 显示跟进信息弹窗
function showFollowupModal(supplierId) {
currentSupplierId = supplierId;
const followupModalEl = document.getElementById('followupModal');
const followupContentEl = document.getElementById('followupContent');
const followupCharCountEl = document.getElementById('followupCharCount');
if (followupContentEl) {
followupContentEl.value = '';
followupContentEl.focus();
}
if (followupCharCountEl) {
followupCharCountEl.textContent = '0';
}
if (followupModalEl) {
followupModalEl.style.display = 'flex';
}
}
// 确认保存跟进信息
async function confirmFollowup() {
const followupContentEl = document.getElementById('followupContent');
const followupModalEl = document.getElementById('followupModal');
const content = followupContentEl ? followupContentEl.value.trim() : '';
if (!content) {
alert('请输入跟进信息');
return;
}
try {
const response = await fetch(`/api/suppliers/${currentSupplierId}/followup?_t=${Date.now()}`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({ content })
});
if (!response.ok) {
throw new Error('服务器响应异常');
}
const data = await response.json();
if (data.success) {
if (followupModalEl) {
followupModalEl.style.display = 'none';
}
loadSuppliers();
showSuccessModal('跟进信息保存成功');
} else {
alert(data.message || '保存跟进信息失败');
}
} catch (error) {
console.error('保存跟进信息失败:', error);
alert('网络错误,请稍后重试');
}
}
// 为终止合作模态框添加事件监听 // 为终止合作模态框添加事件监听
const terminateModalEl = document.getElementById('terminateModal'); const terminateModalEl = document.getElementById('terminateModal');
if (terminateModalEl) { if (terminateModalEl) {
@ -1932,6 +2029,47 @@
}); });
} }
// 为跟进信息模态框添加事件监听
const followupModalEl = document.getElementById('followupModal');
if (followupModalEl) {
const followupContentEl = document.getElementById('followupContent');
const followupCharCountEl = document.getElementById('followupCharCount');
const cancelFollowupBtnEl = document.getElementById('cancelFollowupBtn');
const confirmFollowupBtnEl = document.getElementById('confirmFollowupBtn');
// 字符计数
if (followupContentEl && followupCharCountEl) {
followupContentEl.addEventListener('input', () => {
const length = followupContentEl.value.length;
followupCharCountEl.textContent = length;
followupCharCountEl.style.color = length > 800 ? '#ff4d4f' : '#999';
});
}
// 取消按钮
if (cancelFollowupBtnEl) {
cancelFollowupBtnEl.addEventListener('click', function(e) {
e.preventDefault();
followupModalEl.style.display = 'none';
});
}
// 确认保存按钮
if (confirmFollowupBtnEl) {
confirmFollowupBtnEl.addEventListener('click', function(e) {
e.preventDefault();
confirmFollowup();
});
}
// 点击模态框外部关闭
followupModalEl.addEventListener('click', (e) => {
if (e.target === followupModalEl) {
followupModalEl.style.display = 'none';
}
});
}
// 绑定成功弹窗的确认按钮 // 绑定成功弹窗的确认按钮
document.getElementById('successConfirmBtn').addEventListener('click', closeSuccessModal); document.getElementById('successConfirmBtn').addEventListener('click', closeSuccessModal);
@ -1982,6 +2120,8 @@
window.showTerminateModal = showTerminateModal; window.showTerminateModal = showTerminateModal;
window.confirmTerminate = confirmTerminate; window.confirmTerminate = confirmTerminate;
window.confirmSupplierToCooperation = confirmSupplierToCooperation; window.confirmSupplierToCooperation = confirmSupplierToCooperation;
window.showFollowupModal = showFollowupModal;
window.confirmFollowup = confirmFollowup;
window.loadSuppliers = loadSuppliers; window.loadSuppliers = loadSuppliers;
</script> </script>

Loading…
Cancel
Save