feat(sj_1.2.0-beta2): 状态修改新增二次确认
This commit is contained in:
parent
4bde374d44
commit
72819af4ae
@ -1,36 +1,54 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { ref } from 'vue';
|
import { useBoolean } from '@sa/hooks';
|
||||||
|
import { enableStatusNumberRecord } from '@/constants/business';
|
||||||
|
|
||||||
defineOptions({
|
defineOptions({
|
||||||
name: 'StatusSwitch'
|
name: 'StatusSwitch'
|
||||||
});
|
});
|
||||||
|
|
||||||
const props = defineProps({
|
interface Props {
|
||||||
disabled: Boolean
|
disabled?: boolean;
|
||||||
|
info?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
const props = withDefaults(defineProps<Props>(), {
|
||||||
|
disabled: false,
|
||||||
|
info: ''
|
||||||
});
|
});
|
||||||
|
|
||||||
const modelValue = defineModel<Api.Common.EnableStatusNumber>('value', { default: 0 });
|
const value = defineModel<Api.Common.EnableStatusNumber>('value', { required: false, default: 0 });
|
||||||
|
|
||||||
interface Emits {
|
interface Emits {
|
||||||
(e: 'fetch', value: Api.Common.EnableStatusNumber, callback: () => void): void;
|
(e: 'submitted', value: Api.Common.EnableStatusNumber, callback: (flag: boolean) => void): void;
|
||||||
}
|
}
|
||||||
|
|
||||||
const emit = defineEmits<Emits>();
|
const emit = defineEmits<Emits>();
|
||||||
|
|
||||||
/** 状态切换过程的 loading 状态 */
|
/** 状态切换过程的 loading 状态 */
|
||||||
const loading = ref(false);
|
const { bool: loading, setTrue: startLoading, setFalse: endLoading } = useBoolean();
|
||||||
|
|
||||||
const handleUpdateValue = (value: Api.Common.EnableStatusNumber) => {
|
const handleUpdateValue = (val: Api.Common.EnableStatusNumber) => {
|
||||||
loading.value = true;
|
value.value = val === 0 ? 1 : 0;
|
||||||
emit('fetch', value, () => {
|
window.$dialog?.warning({
|
||||||
loading.value = false;
|
title: '系统提示',
|
||||||
|
content: `确定要${enableStatusNumberRecord[val]}${props.info}吗?`,
|
||||||
|
positiveText: '确定',
|
||||||
|
negativeText: '取消',
|
||||||
|
onPositiveClick: () => {
|
||||||
|
startLoading();
|
||||||
|
emit('submitted', val, flag => {
|
||||||
|
if (flag) value.value = val;
|
||||||
|
endLoading();
|
||||||
|
});
|
||||||
|
},
|
||||||
|
onNegativeClick: () => {}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<NSwitch
|
<NSwitch
|
||||||
:value="modelValue"
|
v-model:value="value"
|
||||||
:loading="loading"
|
:loading="loading"
|
||||||
:rubber-band="false"
|
:rubber-band="false"
|
||||||
:checked-value="1"
|
:checked-value="1"
|
||||||
|
@ -61,17 +61,17 @@ const { columns, columnChecks, data, getData, loading, mobilePagination, searchP
|
|||||||
align: 'center',
|
align: 'center',
|
||||||
width: 80,
|
width: 80,
|
||||||
render: row => {
|
render: row => {
|
||||||
const fetchFn = async (groupStatus: Api.Common.EnableStatusNumber, callback: () => void) => {
|
const fetchFn = async (groupStatus: Api.Common.EnableStatusNumber, callback: (flag: boolean) => void) => {
|
||||||
const status = row.groupStatus === 1 ? 0 : 1;
|
const status = row.groupStatus === 1 ? 0 : 1;
|
||||||
const { error } = await fetchUpdateGroupStatus({ groupName: row.groupName, groupStatus: status });
|
const { error } = await fetchUpdateGroupStatus({ groupName: row.groupName, groupStatus: status });
|
||||||
if (!error) {
|
if (!error) {
|
||||||
row.groupStatus = groupStatus;
|
row.groupStatus = groupStatus;
|
||||||
window.$message?.success($t('common.updateSuccess'));
|
window.$message?.success($t('common.updateSuccess'));
|
||||||
}
|
}
|
||||||
callback();
|
callback(!error);
|
||||||
};
|
};
|
||||||
return (
|
return (
|
||||||
<StatusSwitch v-model:value={row.groupStatus} onFetch={fetchFn} disabled={hasAuth('R_USER') as boolean} />
|
<StatusSwitch v-model:value={row.groupStatus} onSubmitted={fetchFn} disabled={hasAuth('R_USER') as boolean} />
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -83,16 +83,16 @@ const { columnChecks, columns, data, getData, loading, mobilePagination, searchP
|
|||||||
align: 'center',
|
align: 'center',
|
||||||
width: 60,
|
width: 60,
|
||||||
render: row => {
|
render: row => {
|
||||||
const fetchFn = async (jobStatus: Api.Common.EnableStatusNumber, callback: () => void) => {
|
const fetchFn = async (jobStatus: Api.Common.EnableStatusNumber, callback: (flag: boolean) => void) => {
|
||||||
const { error } = await fetchUpdateJobStatus({ id: row.id!, jobStatus });
|
const { error } = await fetchUpdateJobStatus({ id: row.id!, jobStatus });
|
||||||
if (!error) {
|
if (!error) {
|
||||||
row.jobStatus = jobStatus;
|
row.jobStatus = jobStatus;
|
||||||
window.$message?.success($t('common.updateSuccess'));
|
window.$message?.success($t('common.updateSuccess'));
|
||||||
}
|
}
|
||||||
callback();
|
callback(!error);
|
||||||
};
|
};
|
||||||
|
|
||||||
return <StatusSwitch v-model:value={row.jobStatus} onFetch={fetchFn} />;
|
return <StatusSwitch v-model:value={row.jobStatus} onSubmitted={fetchFn} />;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -90,16 +90,16 @@ const { columns, columnChecks, data, getData, loading, mobilePagination, searchP
|
|||||||
align: 'left',
|
align: 'left',
|
||||||
width: 120,
|
width: 120,
|
||||||
render: row => {
|
render: row => {
|
||||||
const fetchFn = async (notifyStatus: Api.Common.EnableStatusNumber, callback: () => void) => {
|
const fetchFn = async (notifyStatus: Api.Common.EnableStatusNumber, callback: (flag: boolean) => void) => {
|
||||||
const { error } = await fetchUpdateNotifyStatus(row.id!, notifyStatus);
|
const { error } = await fetchUpdateNotifyStatus(row.id!, notifyStatus);
|
||||||
if (!error) {
|
if (!error) {
|
||||||
row.notifyStatus = notifyStatus;
|
row.notifyStatus = notifyStatus;
|
||||||
window.$message?.success($t('common.updateSuccess'));
|
window.$message?.success($t('common.updateSuccess'));
|
||||||
}
|
}
|
||||||
callback();
|
callback(!error);
|
||||||
};
|
};
|
||||||
|
|
||||||
return <StatusSwitch v-model:value={row.notifyStatus} onFetch={fetchFn} />;
|
return <StatusSwitch v-model:value={row.notifyStatus} onSubmitted={fetchFn} />;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -81,16 +81,16 @@ const { columns, columnChecks, data, getData, loading, mobilePagination, searchP
|
|||||||
align: 'left',
|
align: 'left',
|
||||||
width: 50,
|
width: 50,
|
||||||
render: row => {
|
render: row => {
|
||||||
const fetchFn = async (sceneStatus: Api.Common.EnableStatusNumber, callback: () => void) => {
|
const fetchFn = async (sceneStatus: Api.Common.EnableStatusNumber, callback: (flag: boolean) => void) => {
|
||||||
const { error } = await fetchUpdateSceneStatus(row.id!, sceneStatus);
|
const { error } = await fetchUpdateSceneStatus(row.id!, sceneStatus);
|
||||||
if (!error) {
|
if (!error) {
|
||||||
row.sceneStatus = sceneStatus;
|
row.sceneStatus = sceneStatus;
|
||||||
window.$message?.success($t('common.updateSuccess'));
|
window.$message?.success($t('common.updateSuccess'));
|
||||||
}
|
}
|
||||||
callback();
|
callback(!error);
|
||||||
};
|
};
|
||||||
|
|
||||||
return <StatusSwitch v-model:value={row.sceneStatus} onFetch={fetchFn} />;
|
return <StatusSwitch v-model:value={row.sceneStatus} onSubmitted={fetchFn} />;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -81,16 +81,16 @@ const { columns, columnChecks, data, getData, loading, mobilePagination, searchP
|
|||||||
align: 'left',
|
align: 'left',
|
||||||
minWidth: 120,
|
minWidth: 120,
|
||||||
render: row => {
|
render: row => {
|
||||||
const fetchFn = async (workflowStatus: Api.Common.EnableStatusNumber, callback: () => void) => {
|
const fetchFn = async (workflowStatus: Api.Common.EnableStatusNumber, callback: (flag: boolean) => void) => {
|
||||||
const { error } = await fetchUpdateWorkflowStatus(row.id!);
|
const { error } = await fetchUpdateWorkflowStatus(row.id!);
|
||||||
if (!error) {
|
if (!error) {
|
||||||
row.workflowStatus = workflowStatus;
|
row.workflowStatus = workflowStatus;
|
||||||
window.$message?.success($t('common.updateSuccess'));
|
window.$message?.success($t('common.updateSuccess'));
|
||||||
}
|
}
|
||||||
callback();
|
callback(!error);
|
||||||
};
|
};
|
||||||
|
|
||||||
return <StatusSwitch v-model:value={row.workflowStatus} onFetch={fetchFn} />;
|
return <StatusSwitch v-model:value={row.workflowStatus} onSubmitted={fetchFn} />;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user