fix: improve work name management and validation logic
Some checks failed
Spell Check / Spell Check with Typos (push) Failing after 6s
Some checks failed
Spell Check / Spell Check with Typos (push) Failing after 6s
This commit is contained in:
parent
cd86e7718a
commit
de281ea79f
4 changed files with 28 additions and 22 deletions
|
|
@ -60,6 +60,7 @@ import {
|
|||
ServiceById,
|
||||
WorkItems,
|
||||
Attributes,
|
||||
WorkCreate,
|
||||
} from 'stores/product-service/types';
|
||||
import { computed } from 'vue';
|
||||
import {
|
||||
|
|
@ -1448,17 +1449,11 @@ function confirmDeleteWork(id: string, noDialog?: boolean) {
|
|||
}
|
||||
}
|
||||
|
||||
function triggerConfirmCloseWork() {
|
||||
function triggerConfirmCloseWorkName() {
|
||||
dialogWarningClose(t, {
|
||||
message: t('dialog.message.warningClose'),
|
||||
action: () => {
|
||||
manageWorkNameDialog.value = false;
|
||||
if (workNameItems.value[workNameItems.value.length - 1].name === '') {
|
||||
confirmDeleteWork(
|
||||
workNameItems.value[workNameItems.value.length - 1].id,
|
||||
true,
|
||||
);
|
||||
}
|
||||
},
|
||||
cancel: () => {},
|
||||
});
|
||||
|
|
@ -1888,6 +1883,20 @@ async function copy(id: string) {
|
|||
dialogService.value = true;
|
||||
}
|
||||
|
||||
function addWorkName(data: { name: string; order: number }) {
|
||||
workNameItems.value.push({ id: '', name: data.name, isEdit: true });
|
||||
}
|
||||
|
||||
async function submitWorkName(
|
||||
workId: string,
|
||||
data: Partial<WorkCreate & { status: string }>,
|
||||
) {
|
||||
if (workNameItems.value.length === 0) return;
|
||||
|
||||
if (!workId) await createWork({ ...data, order: 1 });
|
||||
else await editWork(workId, data);
|
||||
}
|
||||
|
||||
watch(
|
||||
() => formService.value.attributes.workflowId,
|
||||
async (a, b) => {
|
||||
|
|
@ -4669,7 +4678,7 @@ watch(
|
|||
? workNameRef.isWorkNameEdit()
|
||||
: false;
|
||||
if (isWorkNameEdit) {
|
||||
triggerConfirmCloseWork();
|
||||
triggerConfirmCloseWorkName();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
|
@ -4681,8 +4690,8 @@ watch(
|
|||
ref="workNameRef"
|
||||
v-model:name-list="workNameItems"
|
||||
@delete="confirmDeleteWork"
|
||||
@edit="editWork"
|
||||
@add="createWork"
|
||||
@edit="submitWorkName"
|
||||
@add="addWorkName"
|
||||
/>
|
||||
</div>
|
||||
</DialogForm>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue