feat: enhance credit note functionality and improve task order handling
This commit is contained in:
parent
91c7db7c7b
commit
dc225ac31b
3 changed files with 125 additions and 36 deletions
|
|
@ -23,7 +23,9 @@ const emit = defineEmits<{
|
|||
|
||||
const props = defineProps<{
|
||||
taskListGroup?: {
|
||||
product: RequestWork['productService']['product'];
|
||||
product:
|
||||
| RequestWork['productService']['product']
|
||||
| RequestWork['productService'];
|
||||
list: (RequestWork & {
|
||||
_template?: {
|
||||
id: string;
|
||||
|
|
@ -135,6 +137,7 @@ async function getList() {
|
|||
}
|
||||
|
||||
function getStep(requestWork: RequestWork) {
|
||||
if (!requestWork.stepStatus) return 0;
|
||||
const target = requestWork.stepStatus.find(
|
||||
(v) =>
|
||||
v.workStatus === RequestWorkStatus.Ready ||
|
||||
|
|
@ -166,7 +169,7 @@ function submit() {
|
|||
requestWorkStep?: Task;
|
||||
}[] = [];
|
||||
selectedEmployee.value.forEach((v, i) => {
|
||||
if (v.stepStatus.length === 0) {
|
||||
if (!v.stepStatus || v.stepStatus.length === 0) {
|
||||
selected.push({
|
||||
step: 0,
|
||||
requestWorkId: v.id || '',
|
||||
|
|
@ -224,7 +227,7 @@ function close() {
|
|||
|
||||
function onDialogOpen() {
|
||||
// assign selected to group
|
||||
!props.creditNote && assignTempGroup();
|
||||
assignTempGroup();
|
||||
|
||||
// match group to check
|
||||
selectedEmployee.value = [];
|
||||
|
|
@ -232,7 +235,7 @@ function onDialogOpen() {
|
|||
const matchingItems = tempGroupEdit.value
|
||||
.flatMap((g) => g.list)
|
||||
.filter((l) => {
|
||||
if (l.stepStatus.length === 0) {
|
||||
if (!l.stepStatus || l.stepStatus.length === 0) {
|
||||
return taskList.value.some(
|
||||
(t) => t.requestWorkStep?.requestWork.id === l.id,
|
||||
);
|
||||
|
|
@ -248,8 +251,12 @@ function onDialogOpen() {
|
|||
function assignTempGroup() {
|
||||
if (!props.taskListGroup) return;
|
||||
props.taskListGroup.forEach((newGroup) => {
|
||||
const productId = props.creditNote
|
||||
? (newGroup.product as RequestWork['productService']).productId
|
||||
: (newGroup.product as RequestWork['productService']['product']).id;
|
||||
|
||||
const existingGroup = tempGroupEdit.value.find(
|
||||
(g) => g.product.id === newGroup.product.id,
|
||||
(g) => g.product.id === productId,
|
||||
);
|
||||
|
||||
if (existingGroup) {
|
||||
|
|
@ -260,7 +267,9 @@ function assignTempGroup() {
|
|||
});
|
||||
} else {
|
||||
tempGroupEdit.value.push({
|
||||
...newGroup,
|
||||
product: props.creditNote
|
||||
? (newGroup.product as RequestWork['productService']).product
|
||||
: (newGroup.product as RequestWork['productService']['product']),
|
||||
list: [...newGroup.list], // Ensure a new reference
|
||||
});
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue