feat: trigger cancel
This commit is contained in:
parent
e44dee0f83
commit
0f8f6202cb
1 changed files with 15 additions and 0 deletions
|
|
@ -2,6 +2,7 @@
|
||||||
// NOTE: Library
|
// NOTE: Library
|
||||||
import { computed, onMounted, reactive, watch } from 'vue';
|
import { computed, onMounted, reactive, watch } from 'vue';
|
||||||
import { storeToRefs } from 'pinia';
|
import { storeToRefs } from 'pinia';
|
||||||
|
import { useI18n } from 'vue-i18n';
|
||||||
|
|
||||||
// NOTE: Components
|
// NOTE: Components
|
||||||
import StatCardComponent from 'src/components/StatCardComponent.vue';
|
import StatCardComponent from 'src/components/StatCardComponent.vue';
|
||||||
|
|
@ -16,10 +17,12 @@ import { column } from './constants';
|
||||||
import useFlowStore from 'src/stores/flow';
|
import useFlowStore from 'src/stores/flow';
|
||||||
import { useRequestList } from 'src/stores/request-list';
|
import { useRequestList } from 'src/stores/request-list';
|
||||||
import { RequestData, RequestDataStatus } from 'src/stores/request-list/types';
|
import { RequestData, RequestDataStatus } from 'src/stores/request-list/types';
|
||||||
|
import { dialogWarningClose } from 'src/stores/utils';
|
||||||
|
|
||||||
const navigatorStore = useNavigator();
|
const navigatorStore = useNavigator();
|
||||||
const flowStore = useFlowStore();
|
const flowStore = useFlowStore();
|
||||||
const requestListStore = useRequestList();
|
const requestListStore = useRequestList();
|
||||||
|
const { t } = useI18n();
|
||||||
const { data, stats, page, pageMax, pageSize } = storeToRefs(requestListStore);
|
const { data, stats, page, pageMax, pageSize } = storeToRefs(requestListStore);
|
||||||
|
|
||||||
// NOTE: Variable
|
// NOTE: Variable
|
||||||
|
|
@ -63,6 +66,17 @@ async function fetchStats() {
|
||||||
if (ret) stats.value = ret;
|
if (ret) stats.value = ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function triggerCancel(id: string) {
|
||||||
|
dialogWarningClose(t, {
|
||||||
|
action: async () => {
|
||||||
|
const res = await requestListStore.cancelRequest(id);
|
||||||
|
if (res) {
|
||||||
|
fetchList();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
function triggerView(opts: { requestData: RequestData }) {
|
function triggerView(opts: { requestData: RequestData }) {
|
||||||
const url = new URL(
|
const url = new URL(
|
||||||
`/request-list/${opts.requestData.id}`,
|
`/request-list/${opts.requestData.id}`,
|
||||||
|
|
@ -288,6 +302,7 @@ watch([() => pageState.inputSearch, () => pageState.statusFilter], () =>
|
||||||
:grid="pageState.gridView"
|
:grid="pageState.gridView"
|
||||||
:visible-columns="pageState.fieldSelected"
|
:visible-columns="pageState.fieldSelected"
|
||||||
@view="(data) => triggerView({ requestData: data })"
|
@view="(data) => triggerView({ requestData: data })"
|
||||||
|
@delete="(data) => triggerCancel(data.id)"
|
||||||
/>
|
/>
|
||||||
</article>
|
</article>
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue