This commit is contained in:
Kyaru
2026-06-28 00:35:31 +08:00
parent 904797e9e9
commit 84e0862356
7 changed files with 12 additions and 8 deletions

View File

@@ -49,7 +49,7 @@ const DETAIL_SELECT = LIST_SELECT
async function list(req, res) {
try {
const { page, pageSize, offset } = pagination(req.query)
const { status, customer_name, contract_no, contract_name, employee_name, id, effective_date_start, effective_date_end } = req.query
const { status, type, customer_name, contract_no, contract_name, employee_name, id, effective_date_start, effective_date_end } = req.query
let where = 'WHERE 1=1'
const params = []
@@ -68,6 +68,10 @@ async function list(req, res) {
where += ' AND c.status = ?'
params.push(status)
}
if (type) {
where += ' AND c.type = ?'
params.push(type)
}
if (contract_name) {
where += ' AND c.contract_name LIKE ?'
params.push(`%${contract_name}%`)
@@ -105,7 +109,7 @@ async function list(req, res) {
)
const [rows] = await pool.query(
`${LIST_SELECT} ${where} ORDER BY c.id DESC LIMIT ? OFFSET ?`,
`${LIST_SELECT} ${where} ORDER BY c.id ASC LIMIT ? OFFSET ?`,
[...params, pageSize, offset]
)