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