fix: handle optional taskListGroup and creditNote checks in file uploads
This commit is contained in:
parent
4e8e270d62
commit
5c9c035d2b
3 changed files with 49 additions and 38 deletions
|
|
@ -22,7 +22,7 @@ const emit = defineEmits<{
|
||||||
}>();
|
}>();
|
||||||
|
|
||||||
const props = defineProps<{
|
const props = defineProps<{
|
||||||
taskListGroup: {
|
taskListGroup?: {
|
||||||
product: RequestWork['productService']['product'];
|
product: RequestWork['productService']['product'];
|
||||||
list: (RequestWork & {
|
list: (RequestWork & {
|
||||||
_template?: {
|
_template?: {
|
||||||
|
|
@ -210,7 +210,7 @@ function close() {
|
||||||
|
|
||||||
function onDialogOpen() {
|
function onDialogOpen() {
|
||||||
// assign selected to group
|
// assign selected to group
|
||||||
assignTempGroup();
|
!props.creditNote && assignTempGroup();
|
||||||
|
|
||||||
// match group to check
|
// match group to check
|
||||||
selectedEmployee.value = [];
|
selectedEmployee.value = [];
|
||||||
|
|
@ -226,6 +226,7 @@ function onDialogOpen() {
|
||||||
}
|
}
|
||||||
|
|
||||||
function assignTempGroup() {
|
function assignTempGroup() {
|
||||||
|
if (!props.taskListGroup) return;
|
||||||
props.taskListGroup.forEach((newGroup) => {
|
props.taskListGroup.forEach((newGroup) => {
|
||||||
const existingGroup = tempGroupEdit.value.find(
|
const existingGroup = tempGroupEdit.value.find(
|
||||||
(g) => g.product.id === newGroup.product.id,
|
(g) => g.product.id === newGroup.product.id,
|
||||||
|
|
|
||||||
|
|
@ -906,11 +906,11 @@ watch([currentFormData.value.taskStatus], () => {
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<AdditionalFileExpansion
|
<AdditionalFileExpansion
|
||||||
|
:readonly="!['create', 'edit'].includes(state.mode || '')"
|
||||||
v-if="
|
v-if="
|
||||||
view === TaskOrderStatus.Pending ||
|
view === TaskOrderStatus.Pending ||
|
||||||
view === TaskOrderStatus.Complete
|
view === TaskOrderStatus.Complete
|
||||||
"
|
"
|
||||||
:readonly="!['create', 'edit'].includes(state.mode || '')"
|
|
||||||
v-model:file-data="fileData"
|
v-model:file-data="fileData"
|
||||||
:transform-url="
|
:transform-url="
|
||||||
async (url: string) => {
|
async (url: string) => {
|
||||||
|
|
@ -931,28 +931,34 @@ watch([currentFormData.value.taskStatus], () => {
|
||||||
@upload="
|
@upload="
|
||||||
async (f) => {
|
async (f) => {
|
||||||
fileList = f;
|
fileList = f;
|
||||||
fileData = [];
|
|
||||||
|
|
||||||
Array.from(f).forEach((el) => {
|
if (!currentFormData.id) {
|
||||||
fileData.push({
|
fileData = [];
|
||||||
name: el.name,
|
|
||||||
progress: 1,
|
Array.from(f).forEach((el) => {
|
||||||
loaded: 0,
|
fileData.push({
|
||||||
total: el.size,
|
name: el.name,
|
||||||
placeholder: true,
|
progress: 1,
|
||||||
url: fileToUrl(el),
|
loaded: 0,
|
||||||
|
total: el.size,
|
||||||
|
placeholder: true,
|
||||||
|
url: fileToUrl(el),
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
} else {
|
||||||
|
await uploadFile(currentFormData.id, f);
|
||||||
if (!currentFormData.id) return;
|
}
|
||||||
|
|
||||||
await uploadFile(currentFormData.id, f);
|
|
||||||
}
|
}
|
||||||
"
|
"
|
||||||
@remove="
|
@remove="
|
||||||
async (n) => {
|
async (n) => {
|
||||||
if (!currentFormData.id) return;
|
if (!currentFormData.id) {
|
||||||
await remove(currentFormData.id, n);
|
const attIndex = fileData.findIndex((v) => v.name === n);
|
||||||
|
|
||||||
|
fileData.splice(attIndex, 1);
|
||||||
|
} else {
|
||||||
|
await remove(currentFormData.id, n);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
"
|
"
|
||||||
/>
|
/>
|
||||||
|
|
|
||||||
|
|
@ -674,32 +674,36 @@ onMounted(async () => {
|
||||||
@upload="
|
@upload="
|
||||||
async (f) => {
|
async (f) => {
|
||||||
attachmentList = f;
|
attachmentList = f;
|
||||||
attachmentData = [];
|
|
||||||
|
|
||||||
Array.from(f).forEach((el) => {
|
if (!creditNoteData) {
|
||||||
attachmentData.push({
|
attachmentData = [];
|
||||||
name: el.name,
|
|
||||||
progress: 1,
|
Array.from(f).forEach((el) => {
|
||||||
loaded: 0,
|
attachmentData.push({
|
||||||
total: el.size,
|
name: el.name,
|
||||||
placeholder: true,
|
progress: 1,
|
||||||
url: fileToUrl(el),
|
loaded: 0,
|
||||||
|
total: el.size,
|
||||||
|
placeholder: true,
|
||||||
|
url: fileToUrl(el),
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
} else {
|
||||||
|
await uploadFile(creditNoteData.id, f);
|
||||||
if (!creditNoteData) return;
|
}
|
||||||
|
|
||||||
await uploadFile(creditNoteData.id, f);
|
|
||||||
}
|
}
|
||||||
"
|
"
|
||||||
@remove="
|
@remove="
|
||||||
async (n) => {
|
async (n) => {
|
||||||
const attIndex = attachmentData.findIndex((v) => v.name === n);
|
if (!creditNoteData) {
|
||||||
|
const attIndex = attachmentData.findIndex(
|
||||||
|
(v) => v.name === n,
|
||||||
|
);
|
||||||
|
|
||||||
attachmentData.splice(attIndex, 1);
|
attachmentData.splice(attIndex, 1);
|
||||||
|
} else {
|
||||||
if (!creditNoteData) return;
|
await remove(creditNoteData.id, n);
|
||||||
await remove(creditNoteData.id, n);
|
}
|
||||||
}
|
}
|
||||||
"
|
"
|
||||||
/>
|
/>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue