feat(outbound)为出库单查询和导出功能添加入库归属单号筛选条件
- 更新前端页面表单,新增归属单号搜索框并绑定对应参数 - 调整后端查询代码中归属单号过滤条件的位置,优化可读性
This commit is contained in:
@@ -341,7 +341,7 @@ function recDefaultRange() {
|
||||
const end = new Date(); const start = new Date(); start.setMonth(start.getMonth() - 3)
|
||||
return [fmt(start), fmt(end)]
|
||||
}
|
||||
const recFilters = reactive({ outboundType: '', status: '', materialCode: '', boxNo: '', ownershipType: '', dateRange: recDefaultRange() })
|
||||
const recFilters = reactive({ outboundType: '', status: '', materialCode: '', boxNo: '', ownershipNo: '', dateRange: recDefaultRange() })
|
||||
const recRows = ref([])
|
||||
const recTotal = ref(0)
|
||||
const loadingRec = ref(false)
|
||||
@@ -357,7 +357,7 @@ async function loadRecords() {
|
||||
status: recFilters.status,
|
||||
materialCode: recFilters.materialCode.trim(),
|
||||
boxNo: recFilters.boxNo.trim(),
|
||||
ownershipType: recFilters.ownershipType,
|
||||
ownershipNo: recFilters.ownershipNo.trim(),
|
||||
page: recPage.current, pageSize: recPage.size
|
||||
}
|
||||
if (Array.isArray(recFilters.dateRange) && recFilters.dateRange.length === 2) {
|
||||
@@ -370,7 +370,7 @@ async function loadRecords() {
|
||||
} finally { loadingRec.value = false }
|
||||
}
|
||||
function searchRec() { recPage.current = 1; loadRecords() }
|
||||
function resetRec() { Object.assign(recFilters, { outboundType: '', status: '', materialCode: '', boxNo: '', dateRange: recDefaultRange() }); searchRec() }
|
||||
function resetRec() { Object.assign(recFilters, { outboundType: '', status: '', materialCode: '', boxNo: '', ownershipNo: '', dateRange: recDefaultRange() }); searchRec() }
|
||||
|
||||
function downloadCSV() {
|
||||
// 时间窗口与列表保持一致:未选/已清空时回落近 3 个月,保证确认框条数 = 实际导出条数
|
||||
@@ -380,6 +380,7 @@ function downloadCSV() {
|
||||
status: recFilters.status,
|
||||
materialCode: recFilters.materialCode.trim(),
|
||||
boxNo: recFilters.boxNo.trim(),
|
||||
ownershipNo: recFilters.ownershipNo.trim(),
|
||||
startDate: dr[0],
|
||||
endDate: dr[1]
|
||||
}, '出库管理.xlsx', { countUrl: '/outbound/query', name: '出库记录' })
|
||||
@@ -634,6 +635,9 @@ onMounted(loadDicts)
|
||||
<el-form-item label="箱号">
|
||||
<el-input v-model="recFilters.boxNo" placeholder="按箱号查询" clearable style="width:160px" @keyup.enter="searchRec" />
|
||||
</el-form-item>
|
||||
<el-form-item label="归属单号">
|
||||
<el-input v-model="recFilters.ownershipNo" placeholder="工单号/科技项目号" clearable style="width:160px" @keyup.enter="searchRec" />
|
||||
</el-form-item>
|
||||
<el-form-item label="时间">
|
||||
<el-date-picker v-model="recFilters.dateRange" type="daterange" value-format="YYYY-MM-DD"
|
||||
range-separator="至" start-placeholder="开始" end-placeholder="结束" style="width:240px" />
|
||||
|
||||
@@ -333,15 +333,15 @@ func queryOutboundHandler(ctx *svc.ServiceContext) http.HandlerFunc {
|
||||
if boxNo != "" {
|
||||
q = q.Where(outboundorder.BoxNoContainsFold(boxNo))
|
||||
}
|
||||
if ownershipNo != "" {
|
||||
q = q.Where(outboundorder.OwnershipNoContainsFold(ownershipNo))
|
||||
}
|
||||
if outboundType != "" {
|
||||
q = q.Where(outboundorder.OutboundTypeEQ(outboundType))
|
||||
}
|
||||
if outboundCategory != "" {
|
||||
q = q.Where(outboundorder.OutboundCategoryEQ(outboundCategory))
|
||||
}
|
||||
if ownershipNo != "" {
|
||||
q = q.Where(outboundorder.OwnershipNoContainsFold(ownershipNo))
|
||||
}
|
||||
if materialName != "" {
|
||||
q = q.Where(outboundorder.MaterialNameContainsFold(materialName))
|
||||
}
|
||||
@@ -628,7 +628,7 @@ func snListJSON(sn []string) string {
|
||||
}
|
||||
|
||||
// exportOutboundHandler 统一主表全部出库记录导出
|
||||
// 不依赖前端分页,一次返回全部(可按类型/工单/物料/箱号过滤),便于整表导出。
|
||||
// 不依赖前端分页,一次返回全部(可按类型/工单/物料/箱号/归属单号过滤),便于整表导出。
|
||||
func exportOutboundHandler(ctx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
outboundType := r.URL.Query().Get("outboundType")
|
||||
@@ -636,6 +636,7 @@ func exportOutboundHandler(ctx *svc.ServiceContext) http.HandlerFunc {
|
||||
orderNo := r.URL.Query().Get("orderNo")
|
||||
materialCode := r.URL.Query().Get("materialCode")
|
||||
boxNo := r.URL.Query().Get("boxNo")
|
||||
ownershipNo := r.URL.Query().Get("ownershipNo")
|
||||
startDate, endDate, rerr := normalizeExportRange(r.URL.Query().Get("startDate"), r.URL.Query().Get("endDate"))
|
||||
if rerr != nil {
|
||||
fail(w, http.StatusBadRequest, rerr.Error())
|
||||
@@ -660,6 +661,9 @@ func exportOutboundHandler(ctx *svc.ServiceContext) http.HandlerFunc {
|
||||
if boxNo != "" {
|
||||
q = q.Where(outboundorder.BoxNoContainsFold(boxNo))
|
||||
}
|
||||
if ownershipNo != "" {
|
||||
q = q.Where(outboundorder.OwnershipNoContainsFold(ownershipNo))
|
||||
}
|
||||
|
||||
list, err := q.Order(ent.Desc("created_at"), ent.Desc("id")).All(ctx0())
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user