작업계획서대로 진행
This commit is contained in:
@@ -8,7 +8,10 @@ export default defineEventHandler(async (event) => {
|
||||
const projectId = getRouterParam(event, 'id')
|
||||
|
||||
const project = await queryOne<any>(`
|
||||
SELECT * FROM wr_project_info WHERE project_id = $1
|
||||
SELECT p.*, b.business_name, b.business_code
|
||||
FROM wr_project_info p
|
||||
LEFT JOIN wr_business b ON p.business_id = b.business_id
|
||||
WHERE p.project_id = $1
|
||||
`, [projectId])
|
||||
|
||||
if (!project) {
|
||||
@@ -35,6 +38,9 @@ export default defineEventHandler(async (event) => {
|
||||
endDate: project.end_date,
|
||||
contractAmount: project.contract_amount,
|
||||
projectStatus: project.project_status,
|
||||
businessId: project.business_id,
|
||||
businessName: project.business_name,
|
||||
businessCode: project.business_code,
|
||||
createdAt: project.created_at,
|
||||
updatedAt: project.updated_at,
|
||||
currentPm: pm ? { employeeId: pm.employee_id, employeeName: pm.employee_name } : null,
|
||||
|
||||
@@ -11,6 +11,7 @@ interface UpdateProjectBody {
|
||||
endDate?: string
|
||||
contractAmount?: number
|
||||
projectStatus?: string
|
||||
businessId?: number | null
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -46,10 +47,11 @@ export default defineEventHandler(async (event) => {
|
||||
end_date = $6,
|
||||
contract_amount = $7,
|
||||
project_status = $8,
|
||||
business_id = $9,
|
||||
updated_at = NOW(),
|
||||
updated_ip = $9,
|
||||
updated_email = $10
|
||||
WHERE project_id = $11
|
||||
updated_ip = $10,
|
||||
updated_email = $11
|
||||
WHERE project_id = $12
|
||||
`, [
|
||||
body.projectName ?? existing.project_name,
|
||||
body.projectType ?? existing.project_type ?? 'SI',
|
||||
@@ -59,6 +61,7 @@ export default defineEventHandler(async (event) => {
|
||||
body.endDate ?? existing.end_date,
|
||||
body.contractAmount ?? existing.contract_amount,
|
||||
body.projectStatus ?? existing.project_status,
|
||||
body.businessId !== undefined ? body.businessId : existing.business_id,
|
||||
clientIp,
|
||||
userEmail,
|
||||
projectId
|
||||
|
||||
@@ -10,6 +10,7 @@ interface CreateProjectBody {
|
||||
startDate?: string
|
||||
endDate?: string
|
||||
contractAmount?: number
|
||||
businessId?: number | null
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -62,9 +63,9 @@ export default defineEventHandler(async (event) => {
|
||||
const project = await insertReturning(`
|
||||
INSERT INTO wr_project_info (
|
||||
project_code, project_name, project_type, client_name, project_description,
|
||||
start_date, end_date, contract_amount,
|
||||
start_date, end_date, contract_amount, business_id,
|
||||
created_ip, created_email, updated_ip, updated_email
|
||||
) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $9, $10)
|
||||
) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $10, $11)
|
||||
RETURNING *
|
||||
`, [
|
||||
projectCode,
|
||||
@@ -75,6 +76,7 @@ export default defineEventHandler(async (event) => {
|
||||
body.startDate || null,
|
||||
body.endDate || null,
|
||||
body.contractAmount || null,
|
||||
body.businessId || null,
|
||||
clientIp,
|
||||
userEmail
|
||||
])
|
||||
@@ -85,7 +87,8 @@ export default defineEventHandler(async (event) => {
|
||||
projectId: project.project_id,
|
||||
projectCode: project.project_code,
|
||||
projectName: project.project_name,
|
||||
projectType: project.project_type
|
||||
projectType: project.project_type,
|
||||
businessId: project.business_id
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
@@ -7,9 +7,11 @@ import { query } from '../../utils/db'
|
||||
export default defineEventHandler(async (event) => {
|
||||
const queryParams = getQuery(event)
|
||||
const status = queryParams.status as string || null
|
||||
const businessId = queryParams.businessId ? Number(queryParams.businessId) : null
|
||||
|
||||
let sql = `
|
||||
SELECT p.*,
|
||||
b.business_name,
|
||||
(SELECT employee_name FROM wr_employee_info e
|
||||
JOIN wr_project_manager_history pm ON e.employee_id = pm.employee_id
|
||||
WHERE pm.project_id = p.project_id AND pm.role_type = 'PM'
|
||||
@@ -21,14 +23,27 @@ export default defineEventHandler(async (event) => {
|
||||
AND (pm.end_date IS NULL OR pm.end_date >= CURRENT_DATE)
|
||||
LIMIT 1) as pl_name
|
||||
FROM wr_project_info p
|
||||
LEFT JOIN wr_business b ON p.business_id = b.business_id
|
||||
`
|
||||
|
||||
const conditions: string[] = []
|
||||
const params: any[] = []
|
||||
let paramIndex = 1
|
||||
|
||||
if (status) {
|
||||
sql += ' WHERE p.project_status = $1'
|
||||
conditions.push(`p.project_status = $${paramIndex++}`)
|
||||
params.push(status)
|
||||
}
|
||||
|
||||
if (businessId) {
|
||||
conditions.push(`p.business_id = $${paramIndex++}`)
|
||||
params.push(businessId)
|
||||
}
|
||||
|
||||
if (conditions.length > 0) {
|
||||
sql += ' WHERE ' + conditions.join(' AND ')
|
||||
}
|
||||
|
||||
sql += ' ORDER BY p.created_at DESC'
|
||||
|
||||
const projects = await query(sql, params)
|
||||
@@ -45,6 +60,8 @@ export default defineEventHandler(async (event) => {
|
||||
endDate: p.end_date,
|
||||
contractAmount: p.contract_amount,
|
||||
projectStatus: p.project_status,
|
||||
businessId: p.business_id,
|
||||
businessName: p.business_name,
|
||||
pmName: p.pm_name,
|
||||
plName: p.pl_name,
|
||||
createdAt: p.created_at
|
||||
|
||||
Reference in New Issue
Block a user