Compare commits
2
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5109d8b3e5 | ||
|
|
2a0a2ef72a |
No files matched your search
@@ -94,7 +94,7 @@ def apply_planned_start_time_step_filter(
|
||||
planned_start_time_end: Optional[str] = None,
|
||||
mine_user_id: Optional[str] = None,
|
||||
):
|
||||
"""按活跃工单/任务下未完成工艺步骤的计划开始时间过滤。"""
|
||||
"""按工艺步骤计划开始时间过滤;工单/任务/步骤状态由外层检索条件组合控制。"""
|
||||
start = (planned_start_time_start or "").strip()
|
||||
end = (planned_start_time_end or "").strip()
|
||||
if not start and not end:
|
||||
@@ -104,15 +104,9 @@ def apply_planned_start_time_step_filter(
|
||||
BizProductionTaskStep.del_flag == 0,
|
||||
BizProductionTaskStep.tenant_no == tenant_no,
|
||||
BizProductionTaskStep.planned_start_time.isnot(None),
|
||||
BizProductionTaskStep.step_status != "ywc",
|
||||
BizProductionTask.id == BizProductionTaskStep.task_id,
|
||||
BizProductionTask.del_flag == 0,
|
||||
BizProductionTask.tenant_no == tenant_no,
|
||||
BizProductionTask.task_status.in_(("dpz", "jxz")),
|
||||
BizProductionWorkOrder.id == BizProductionTask.work_order_id,
|
||||
BizProductionWorkOrder.del_flag == 0,
|
||||
BizProductionWorkOrder.tenant_no == tenant_no,
|
||||
BizProductionWorkOrder.work_order_status.in_(("dpz", "jxz")),
|
||||
work_order_id_column == BizProductionTask.work_order_id,
|
||||
]
|
||||
if start:
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
"""计划开始时间筛选:不内置工单/任务/步骤状态限制,交给外层组合条件。"""
|
||||
|
||||
from sqlalchemy import create_engine
|
||||
from sqlalchemy.dialects import mysql
|
||||
from sqlalchemy.orm import sessionmaker
|
||||
|
||||
from app.crud.production_work_order import apply_planned_start_time_step_filter
|
||||
from app.models.models import BizProductionWorkOrder
|
||||
|
||||
|
||||
def _compile_planned_start_sql() -> str:
|
||||
eng = create_engine("sqlite://")
|
||||
SessionLocal = sessionmaker(bind=eng)
|
||||
db = SessionLocal()
|
||||
try:
|
||||
q = db.query(BizProductionWorkOrder).filter(BizProductionWorkOrder.del_flag == 0)
|
||||
filtered = apply_planned_start_time_step_filter(
|
||||
q,
|
||||
tenant_no="zkxw",
|
||||
work_order_id_column=BizProductionWorkOrder.id,
|
||||
planned_start_time_start="2026-10-01",
|
||||
planned_start_time_end="2026-12-31",
|
||||
)
|
||||
return str(
|
||||
filtered.statement.compile(
|
||||
dialect=mysql.dialect(), compile_kwargs={"literal_binds": True}
|
||||
)
|
||||
)
|
||||
finally:
|
||||
db.close()
|
||||
|
||||
|
||||
def test_planned_start_filter_keeps_date_bounds_without_status_hardcodes():
|
||||
sql = _compile_planned_start_sql().lower()
|
||||
assert "planned_start_time" in sql
|
||||
assert "2026-10-01 00:00:00" in sql
|
||||
assert "2026-12-31 23:59:59" in sql
|
||||
# 不再在 EXISTS 内强制待配置/进行中或未完成步骤
|
||||
assert "work_order_status in (" not in sql
|
||||
assert "task_status in (" not in sql
|
||||
assert "step_status !=" not in sql
|
||||
assert "step_status <>" not in sql
|
||||
@@ -78,15 +78,41 @@
|
||||
<el-icon><RefreshRight /></el-icon>重试
|
||||
</el-button>
|
||||
</el-alert>
|
||||
<div v-if="assignment" class="list-toolbar">
|
||||
<div class="list-toolbar-row">
|
||||
<div class="list-toolbar-selected">
|
||||
已选 <span class="sel-num">{{ selectedRows.length }}</span> 项
|
||||
</div>
|
||||
<el-button
|
||||
type="primary"
|
||||
class="btn-main"
|
||||
:disabled="!selectedRows.length || busy"
|
||||
@click="openBatch"
|
||||
>
|
||||
<el-icon><Edit /></el-icon>调整归属
|
||||
</el-button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="list-body list-wrap"
|
||||
><el-table
|
||||
ref="tableRef"
|
||||
:key="query.bizType"
|
||||
:data="rows"
|
||||
v-loading="loading"
|
||||
class="list-table"
|
||||
stripe
|
||||
row-key="id"
|
||||
:empty-text="loading ? '正在加载…' : loadError ? '数据加载失败' : '暂无符合条件的单据'"
|
||||
@selection-change="handleSelectionChange"
|
||||
>
|
||||
<el-table-column
|
||||
v-if="assignment"
|
||||
type="selection"
|
||||
min-width="48"
|
||||
align="center"
|
||||
header-align="center"
|
||||
fixed
|
||||
/>
|
||||
<el-table-column
|
||||
type="index"
|
||||
label="序号"
|
||||
@@ -151,26 +177,26 @@
|
||||
>
|
||||
<el-form class="form-grid-2" label-position="top">
|
||||
<el-form-item label="原所属项目组">
|
||||
<el-input :model-value="selected.teamName || '未归属'" disabled />
|
||||
<el-input :model-value="originalTeamLabel" disabled />
|
||||
</el-form-item>
|
||||
<el-form-item label="原所属项目">
|
||||
<el-input :model-value="selected.projectName || '未归属'" disabled />
|
||||
<el-input :model-value="originalProjectLabel" disabled />
|
||||
</el-form-item>
|
||||
<el-form-item label="新项目组" required>
|
||||
<ProjectSelect
|
||||
:key="`team-${selected.id}`"
|
||||
:key="`team-${dialogSelectKey}`"
|
||||
team
|
||||
v-model="targetTeamId"
|
||||
:biz-type="selected.bizType"
|
||||
:biz-type="dialogBizType"
|
||||
@update:model-value="onTargetTeamChange"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="新项目" required>
|
||||
<ProjectSelect
|
||||
:key="`project-${selected.id}-${targetTeamId}`"
|
||||
:key="`project-${dialogSelectKey}-${targetTeamId}`"
|
||||
v-model="target"
|
||||
:team-id="targetTeamId"
|
||||
:biz-type="selected.bizType"
|
||||
:biz-type="dialogBizType"
|
||||
:disabled="!targetTeamId"
|
||||
/>
|
||||
</el-form-item>
|
||||
@@ -262,6 +288,7 @@
|
||||
page: 1,
|
||||
pageSize: 20
|
||||
})
|
||||
const tableRef = ref<{ clearSelection?: () => void } | null>(null)
|
||||
const rows = ref<ProjectRecord[]>([]),
|
||||
total = ref(0),
|
||||
statusCounts = ref<Record<string, number>>({}),
|
||||
@@ -273,6 +300,8 @@
|
||||
target = ref(''),
|
||||
reason = ref(''),
|
||||
selected = ref<ProjectRecord>({}),
|
||||
selectedRows = ref<ProjectRecord[]>([]),
|
||||
editTargets = ref<ProjectRecord[]>([]),
|
||||
historyVisible = ref(false),
|
||||
historyRows = ref<ProjectRecord[]>([])
|
||||
const visibleColumns = computed(() =>
|
||||
@@ -283,6 +312,39 @@
|
||||
const keywordHint = computed(() =>
|
||||
query.bizType === 'presign' ? '请输入单据编号' : assignmentKeywordHints[query.bizType]
|
||||
)
|
||||
const dialogBizType = computed(
|
||||
() =>
|
||||
(editTargets.value[0]?.bizType ||
|
||||
selected.value.bizType ||
|
||||
query.bizType) as AssignmentBizType
|
||||
)
|
||||
const dialogSelectKey = computed(() => {
|
||||
if (editTargets.value.length <= 1) {
|
||||
return String(editTargets.value[0]?.id || selected.value.id || 'empty')
|
||||
}
|
||||
const firstId = editTargets.value[0]?.id || ''
|
||||
const lastId = editTargets.value[editTargets.value.length - 1]?.id || ''
|
||||
return `batch-${editTargets.value.length}-${firstId}-${lastId}`
|
||||
})
|
||||
const originalTeamLabel = computed(() => {
|
||||
if (editTargets.value.length <= 1) {
|
||||
return editTargets.value[0]?.teamName || selected.value.teamName || '未归属'
|
||||
}
|
||||
return `共 ${editTargets.value.length} 条`
|
||||
})
|
||||
const originalProjectLabel = computed(() => {
|
||||
if (editTargets.value.length <= 1) {
|
||||
return editTargets.value[0]?.projectName || selected.value.projectName || '未归属'
|
||||
}
|
||||
return `共 ${editTargets.value.length} 条`
|
||||
})
|
||||
function clearSelection() {
|
||||
selectedRows.value = []
|
||||
tableRef.value?.clearSelection?.()
|
||||
}
|
||||
function handleSelectionChange(selection: ProjectRecord[]) {
|
||||
selectedRows.value = selection
|
||||
}
|
||||
let loadVersion = 0
|
||||
function statusLabel(status: string) {
|
||||
return query.bizType === 'presign'
|
||||
@@ -307,6 +369,7 @@
|
||||
loading.value = true
|
||||
loadError.value = false
|
||||
rows.value = []
|
||||
clearSelection()
|
||||
try {
|
||||
const fetchRecords = props.assignment
|
||||
? fetchAssignmentRecords
|
||||
@@ -344,6 +407,7 @@
|
||||
statusCounts.value = {}
|
||||
visible.value = false
|
||||
historyVisible.value = false
|
||||
clearSelection()
|
||||
search()
|
||||
}
|
||||
function switchBusiness(kind: AssignmentBizType) {
|
||||
@@ -360,16 +424,41 @@
|
||||
query.page = page
|
||||
load()
|
||||
}
|
||||
function open(row: ProjectRecord) {
|
||||
selected.value = row
|
||||
function resetDialogForm(targets: ProjectRecord[]) {
|
||||
editTargets.value = targets
|
||||
selected.value = targets[0] || {}
|
||||
targetTeamId.value = ''
|
||||
target.value = ''
|
||||
reason.value = ''
|
||||
visible.value = true
|
||||
}
|
||||
function open(row: ProjectRecord) {
|
||||
resetDialogForm([row])
|
||||
}
|
||||
function openBatch() {
|
||||
if (!selectedRows.value.length) {
|
||||
ElMessage.warning('请先选择要调整的记录')
|
||||
return
|
||||
}
|
||||
resetDialogForm([...selectedRows.value])
|
||||
}
|
||||
function onTargetTeamChange() {
|
||||
target.value = ''
|
||||
}
|
||||
async function assignOne(row: ProjectRecord, projectId: string, assignReason: string) {
|
||||
const preview = await previewAssignment({
|
||||
bizType: row.bizType,
|
||||
id: row.id,
|
||||
projectId
|
||||
})
|
||||
await saveAssignment({
|
||||
bizType: row.bizType,
|
||||
id: row.id,
|
||||
projectId,
|
||||
reason: assignReason,
|
||||
expectedAssignments: assignmentSnapshot(preview.records)
|
||||
})
|
||||
}
|
||||
async function commit() {
|
||||
if (!targetTeamId.value) {
|
||||
ElMessage.warning('请选择新项目组')
|
||||
@@ -383,33 +472,45 @@
|
||||
ElMessage.warning('请填写调整原因')
|
||||
return
|
||||
}
|
||||
const targets = editTargets.value.length ? [...editTargets.value] : [selected.value]
|
||||
if (!targets.length || !targets[0]?.id) {
|
||||
ElMessage.warning('请选择要调整的记录')
|
||||
return
|
||||
}
|
||||
busy.value = true
|
||||
const commitTarget = target.value
|
||||
const commitRecord = selected.value
|
||||
const commitReason = reason.value.trim()
|
||||
const commitTargets = targets
|
||||
let successCount = 0
|
||||
let failCount = 0
|
||||
try {
|
||||
const preview = await previewAssignment({
|
||||
bizType: selected.value.bizType,
|
||||
id: selected.value.id,
|
||||
projectId: target.value
|
||||
})
|
||||
if (selected.value !== commitRecord || target.value !== commitTarget || !visible.value) {
|
||||
for (const row of commitTargets) {
|
||||
if (target.value !== commitTarget || !visible.value) {
|
||||
return
|
||||
}
|
||||
try {
|
||||
await assignOne(row, commitTarget, commitReason)
|
||||
successCount += 1
|
||||
} catch {
|
||||
failCount += 1
|
||||
// API layer already surfaces the conflict / validation message.
|
||||
}
|
||||
}
|
||||
if (target.value !== commitTarget || !visible.value) {
|
||||
return
|
||||
}
|
||||
await saveAssignment({
|
||||
bizType: selected.value.bizType,
|
||||
id: selected.value.id,
|
||||
projectId: target.value,
|
||||
reason: reason.value.trim(),
|
||||
expectedAssignments: assignmentSnapshot(preview.records)
|
||||
})
|
||||
if (selected.value !== commitRecord || target.value !== commitTarget || !visible.value) {
|
||||
return
|
||||
if (successCount > 0) {
|
||||
visible.value = false
|
||||
clearSelection()
|
||||
if (failCount === 0) {
|
||||
ElMessage.success(
|
||||
commitTargets.length > 1 ? `已调整 ${successCount} 条归属` : '归属已调整'
|
||||
)
|
||||
} else {
|
||||
ElMessage.warning(`成功 ${successCount} 条,失败 ${failCount} 条`)
|
||||
}
|
||||
await load()
|
||||
}
|
||||
visible.value = false
|
||||
ElMessage.success('归属已调整')
|
||||
await load()
|
||||
} catch {
|
||||
// API layer already surfaces the conflict / validation message.
|
||||
} finally {
|
||||
busy.value = false
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user