This commit is contained in:
puriphatt 2025-05-22 17:41:55 +07:00
commit 105e91a655
5 changed files with 29 additions and 23 deletions

View file

@ -98,7 +98,8 @@ watch(
(c, o) => { (c, o) => {
const list = c.map((v: { name: string }) => v.name); const list = c.map((v: { name: string }) => v.name);
const oldList = o.map((v: { name: string }) => v.name); const oldList = o.map((v: { name: string }) => v.name);
const index = oldList.indexOf(workName.value || ''); const index = workName.value ? oldList.indexOf(workName.value) : -1;
if (index === -1) return;
if ( if (
list[index] !== oldList[index] && list[index] !== oldList[index] &&
@ -704,8 +705,8 @@ watch(
} }
:deep( :deep(
.q-item__section.column.q-item__section--side.justify-center.q-item__section--avatar.q-focusable.relative-position.cursor-pointer .q-item__section.column.q-item__section--side.justify-center.q-item__section--avatar.q-focusable.relative-position.cursor-pointer
) { ) {
justify-content: start !important; justify-content: start !important;
padding-right: 8px !important; padding-right: 8px !important;
padding-top: 16px; padding-top: 16px;
@ -735,8 +736,8 @@ watch(
} }
:deep( :deep(
i.q-icon.mdi.mdi-chevron-down-circle.q-expansion-item__toggle-icon.q-expansion-item__toggle-icon--rotated i.q-icon.mdi.mdi-chevron-down-circle.q-expansion-item__toggle-icon.q-expansion-item__toggle-icon--rotated
) { ) {
color: var(--brand-1); color: var(--brand-1);
} }

View file

@ -1,7 +1,6 @@
<script lang="ts" setup> <script lang="ts" setup>
import { nextTick, onMounted, ref, watch } from 'vue'; import { nextTick, onMounted, ref, watch } from 'vue';
import { DeleteButton, EditButton, SaveButton, UndoButton } from '../button'; import { DeleteButton, EditButton, SaveButton, UndoButton } from '../button';
import { scrollToElement } from 'stores/utils';
// import { useI18n } from 'vue-i18n'; // import { useI18n } from 'vue-i18n';
// import { storeToRefs } from 'pinia'; // import { storeToRefs } from 'pinia';
@ -138,11 +137,8 @@ watch(
@click=" @click="
() => { () => {
assignClone(); assignClone();
if (nameList[nameList.length - 1].name === '') { cloneList = cloneList.filter((item) => item.name !== '');
$emit('delete', cloneList[cloneList.length - 1].id, true); nameList = nameList.filter((item) => item.name !== '');
cloneList = cloneList.filter((item) => item.name !== '');
nameList = nameList.filter((item) => item.name !== '');
}
} }
" "
/> />

View file

@ -763,7 +763,7 @@ watch(
" "
/> />
<KebabAction <KebabAction
:id-name="props.row.id" :id-name="props.row.name"
:status="props.row.status" :status="props.row.status"
@view=" @view="
() => { () => {

View file

@ -60,6 +60,7 @@ import {
ServiceById, ServiceById,
WorkItems, WorkItems,
Attributes, Attributes,
WorkCreate,
} from 'stores/product-service/types'; } from 'stores/product-service/types';
import { computed } from 'vue'; import { computed } from 'vue';
import { import {
@ -1448,17 +1449,11 @@ function confirmDeleteWork(id: string, noDialog?: boolean) {
} }
} }
function triggerConfirmCloseWork() { function triggerConfirmCloseWorkName() {
dialogWarningClose(t, { dialogWarningClose(t, {
message: t('dialog.message.warningClose'), message: t('dialog.message.warningClose'),
action: () => { action: () => {
manageWorkNameDialog.value = false; manageWorkNameDialog.value = false;
if (workNameItems.value[workNameItems.value.length - 1].name === '') {
confirmDeleteWork(
workNameItems.value[workNameItems.value.length - 1].id,
true,
);
}
}, },
cancel: () => {}, cancel: () => {},
}); });
@ -1888,6 +1883,20 @@ async function copy(id: string) {
dialogService.value = true; 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( watch(
() => formService.value.attributes.workflowId, () => formService.value.attributes.workflowId,
async (a, b) => { async (a, b) => {
@ -4669,7 +4678,7 @@ watch(
? workNameRef.isWorkNameEdit() ? workNameRef.isWorkNameEdit()
: false; : false;
if (isWorkNameEdit) { if (isWorkNameEdit) {
triggerConfirmCloseWork(); triggerConfirmCloseWorkName();
return true; return true;
} }
return false; return false;
@ -4681,8 +4690,8 @@ watch(
ref="workNameRef" ref="workNameRef"
v-model:name-list="workNameItems" v-model:name-list="workNameItems"
@delete="confirmDeleteWork" @delete="confirmDeleteWork"
@edit="editWork" @edit="submitWorkName"
@add="createWork" @add="addWorkName"
/> />
</div> </div>
</DialogForm> </DialogForm>

View file

@ -441,7 +441,7 @@ const useProductServiceStore = defineStore('api-product-service', () => {
...payload, ...payload,
}); });
if (res && res.status < 200) { if (res && res.status < 400) {
await fetchListOfWork(); await fetchListOfWork();
return res.data; return res.data;
} }