|
|
|
|
@ -151,7 +151,7 @@
|
|
|
|
|
@select="handleDetailSelect"
|
|
|
|
|
@select-all="handleDetailSelectAll"
|
|
|
|
|
>
|
|
|
|
|
<el-table-column type="selection" width="55" :reserve-selection="true" align="center" />
|
|
|
|
|
<el-table-column type="selection" width="55" :reserve-selection="true" align="center" :selectable="isDetailRowSelectable" />
|
|
|
|
|
<el-table-column :label="t('ProductionPlan.TaskSummary.detailTableTaskCodeColumn')" align="center" prop="taskCode" sortable width="200px"/>
|
|
|
|
|
<el-table-column :label="t('ProductionPlan.TaskSummary.detailTableProductCodeColumn')" align="center" prop="barCode" sortable />
|
|
|
|
|
<el-table-column :label="t('ProductionPlan.TaskSummary.detailTableProductNameColumn')" align="center" prop="productName" sortable />
|
|
|
|
|
@ -449,7 +449,10 @@ const handleCurrentTaskChange = async (row: any) => {
|
|
|
|
|
const parentIsSelected = taskTableRef.value?.getSelectionRows()?.some((t: any) => t.id === row.id)
|
|
|
|
|
if (parentIsSelected) {
|
|
|
|
|
detailList.value.forEach(child => {
|
|
|
|
|
const unplanNumber = child.number - child.planNumber
|
|
|
|
|
if (unplanNumber > 0) {
|
|
|
|
|
detailTableRef.value?.toggleRowSelection(child, true)
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
@ -474,7 +477,10 @@ const handleTaskSelect = async (selection: any[], row: any) => {
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
detailList.value.forEach((child) => {
|
|
|
|
|
const unplanNumber = child.number - child.planNumber
|
|
|
|
|
if (unplanNumber > 0) {
|
|
|
|
|
detailTableRef.value?.toggleRowSelection(child, true)
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
@ -507,10 +513,13 @@ const handleTaskSelectAll = async (selection: any[]) => {
|
|
|
|
|
taskTableRef.value?.toggleRowSelection(row, false)
|
|
|
|
|
} else {
|
|
|
|
|
childList.forEach((child) => {
|
|
|
|
|
const unplanNumber = child.number - child.planNumber
|
|
|
|
|
if (unplanNumber > 0) {
|
|
|
|
|
const rowInView = detailList.value.find(d => d.id === child.id)
|
|
|
|
|
if (rowInView) {
|
|
|
|
|
detailTableRef.value?.toggleRowSelection(rowInView, true)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
@ -528,10 +537,13 @@ const handleTaskSelectAll = async (selection: any[]) => {
|
|
|
|
|
const handleDetailSelect = (selection: any[], row: any) => {
|
|
|
|
|
const taskId = row.taskId
|
|
|
|
|
const childList = allDetailsMap.value[taskId] || []
|
|
|
|
|
const selectableChildren = childList.filter(child => {
|
|
|
|
|
const unplanNumber = child.number - child.planNumber
|
|
|
|
|
return unplanNumber > 0
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
// check if all children for this task are selected
|
|
|
|
|
const allChildrenSelected = childList.every(child => selection.some(sel => sel.id === child.id))
|
|
|
|
|
const noChildrenSelected = childList.every(child => !selection.some(sel => sel.id === child.id))
|
|
|
|
|
const allChildrenSelected = selectableChildren.length > 0 && selectableChildren.every(child => selection.some(sel => sel.id === child.id))
|
|
|
|
|
const noChildrenSelected = selectableChildren.every(child => !selection.some(sel => sel.id === child.id))
|
|
|
|
|
|
|
|
|
|
const parentTask = taskList.value.find(task => task.id === taskId)
|
|
|
|
|
if (parentTask) {
|
|
|
|
|
@ -548,14 +560,16 @@ const handleDetailSelectAll = (selection: any[]) => {
|
|
|
|
|
|
|
|
|
|
const taskId = currentTask.value.id
|
|
|
|
|
const childList = allDetailsMap.value[taskId] || []
|
|
|
|
|
const selectableChildren = childList.filter(child => {
|
|
|
|
|
const unplanNumber = child.number - child.planNumber
|
|
|
|
|
return unplanNumber > 0
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
const parentTask = taskList.value.find(task => task.id === taskId)
|
|
|
|
|
if (parentTask) {
|
|
|
|
|
// if any child in current view is selected, consider it an intent to select parent (if not all were selected)
|
|
|
|
|
// selection will contain all selected items across pages, so we need to filter for current view's task
|
|
|
|
|
const currentViewSelection = selection.filter(sel => sel.taskId === taskId)
|
|
|
|
|
|
|
|
|
|
if (currentViewSelection.length === childList.length && childList.length > 0) {
|
|
|
|
|
if (selectableChildren.length > 0 && currentViewSelection.length === selectableChildren.length) {
|
|
|
|
|
taskTableRef.value?.toggleRowSelection(parentTask, true)
|
|
|
|
|
} else if (currentViewSelection.length === 0) {
|
|
|
|
|
taskTableRef.value?.toggleRowSelection(parentTask, false)
|
|
|
|
|
@ -565,6 +579,11 @@ const handleDetailSelectAll = (selection: any[]) => {
|
|
|
|
|
|
|
|
|
|
const isTaskRowSelectable = () => !taskTableBusy.value && !detailLoading.value
|
|
|
|
|
|
|
|
|
|
const isDetailRowSelectable = (row: any) => {
|
|
|
|
|
const unplanNumber = row.number - row.planNumber
|
|
|
|
|
return unplanNumber > 0
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const handleSearch = async () => {
|
|
|
|
|
queryParams.pageNo = 1
|
|
|
|
|
await loadTaskList()
|
|
|
|
|
@ -697,14 +716,18 @@ const handleSubmit = async () => {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const selectedRows = detailTableRef.value?.getSelectionRows() || []
|
|
|
|
|
if (selectedRows.length === 0) {
|
|
|
|
|
const filteredRows = selectedRows.filter((row: any) => {
|
|
|
|
|
const unplanNumber = row.number - row.planNumber
|
|
|
|
|
return unplanNumber > 0
|
|
|
|
|
})
|
|
|
|
|
if (filteredRows.length === 0) {
|
|
|
|
|
message.warning(t('ProductionPlan.TaskSummary.selectDetailWarning'))
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
submitLoading.value = true
|
|
|
|
|
try {
|
|
|
|
|
console.log(selectedRows)
|
|
|
|
|
const createReqVO = selectedRows.map((row: any) => {
|
|
|
|
|
console.log(filteredRows)
|
|
|
|
|
const createReqVO = filteredRows.map((row: any) => {
|
|
|
|
|
const planNumber = row.number - row.planNumber > 0 ? row.number - row.planNumber : 0
|
|
|
|
|
return {
|
|
|
|
|
// PlanForm fields
|
|
|
|
|
|