备份:修复前完整项目快照 2026-04-19
This commit is contained in:
@@ -0,0 +1,81 @@
|
||||
// 创建测试分包商
|
||||
const BASE_URL = 'http://localhost:3003/api';
|
||||
|
||||
async function createTestSubcontractor() {
|
||||
console.log('=== 创建测试分包商 ===\n');
|
||||
|
||||
try {
|
||||
// 创建分包商
|
||||
const subcontractorData = {
|
||||
name: '测试分包商有限公司',
|
||||
scope: '建筑工程、装修工程',
|
||||
features: '专业施工团队,10年经验',
|
||||
country: '中国',
|
||||
remark: '测试用的分包商',
|
||||
contacts: [
|
||||
{
|
||||
name: '张经理',
|
||||
position: '项目经理',
|
||||
phone: '13800138000',
|
||||
is_primary: true
|
||||
}
|
||||
],
|
||||
payment_infos: [
|
||||
{
|
||||
account_name: '测试分包商有限公司',
|
||||
bank_account: '6228480012345678901',
|
||||
bank_name: '中国农业银行',
|
||||
qr_code: '',
|
||||
is_primary: true
|
||||
}
|
||||
]
|
||||
};
|
||||
|
||||
console.log('正在创建分包商...');
|
||||
const createRes = await fetch(`${BASE_URL}/subcontractors`, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
body: JSON.stringify(subcontractorData)
|
||||
});
|
||||
|
||||
const createData = await createRes.json();
|
||||
|
||||
if (createData.success) {
|
||||
console.log('分包商创建成功!');
|
||||
console.log(`分包商ID: ${createData.data.id}`);
|
||||
console.log(`分包商名称: ${createData.data.name}`);
|
||||
console.log(`分包商编号: ${createData.data.code}`);
|
||||
|
||||
// 验证分包商详情
|
||||
console.log('\n验证分包商详情...');
|
||||
const detailRes = await fetch(`${BASE_URL}/subcontractors/${createData.data.id}`);
|
||||
const detailData = await detailRes.json();
|
||||
|
||||
if (detailData.success) {
|
||||
console.log('分包商详情获取成功!');
|
||||
console.log(`收款信息数量: ${detailData.data.payment_infos?.length || 0}`);
|
||||
|
||||
if (detailData.data.payment_infos && detailData.data.payment_infos.length > 0) {
|
||||
console.log('收款信息:');
|
||||
detailData.data.payment_infos.forEach((payment, i) => {
|
||||
console.log(` ${i+1}. ${payment.account_name} - ${payment.bank_name} (${payment.bank_account})`);
|
||||
});
|
||||
}
|
||||
} else {
|
||||
console.log('获取分包商详情失败:', detailData.message);
|
||||
}
|
||||
} else {
|
||||
console.log('分包商创建失败:', createData.message);
|
||||
}
|
||||
|
||||
console.log('\n=== 创建完成 ===');
|
||||
|
||||
} catch (error) {
|
||||
console.error('创建失败:', error.message);
|
||||
}
|
||||
}
|
||||
|
||||
// 运行创建
|
||||
createTestSubcontractor();
|
||||
Reference in New Issue
Block a user