feat:【antd】【bpm】model/index.vue 代码评审

pull/239/MERGE
YunaiV 2025-10-24 20:03:30 +08:00
parent d568ab0fe9
commit 9bb554f474
4 changed files with 70 additions and 65 deletions

View File

@ -1,3 +1,4 @@
// TODO @jason要不要新建 bpm/components然后迁移过去
import './styles/simple-process-designer.scss'; import './styles/simple-process-designer.scss';
export { default as HttpRequestSetting } from './components/nodes-config/modules/http-request-setting.vue'; export { default as HttpRequestSetting } from './components/nodes-config/modules/http-request-setting.vue';

View File

@ -24,26 +24,22 @@ const [CategoryFormModal, categoryFormModalApi] = useVbenModal({
connectedComponent: CategoryForm, connectedComponent: CategoryForm,
destroyOnClose: true, destroyOnClose: true,
}); });
//
const modelListSpinning = ref(false); const modelListSpinning = ref(false); //
//
const saveSortLoading = ref(false); const saveSortLoading = ref(false); //
// category const categoryGroup = ref<ModelCategoryInfo[]>([]); // category
const categoryGroup = ref<ModelCategoryInfo[]>([]); const originalData = ref<ModelCategoryInfo[]>([]); //
//
const originalData = ref<ModelCategoryInfo[]>([]); const sortable = useTemplateRef<HTMLElement>('categoryGroupRef'); //
// const sortableInstance = ref<any>(null); // 便
const sortable = useTemplateRef<HTMLElement>('categoryGroupRef'); const isCategorySorting = ref(false); //
// 便
const sortableInstance = ref<any>(null);
//
const isCategorySorting = ref(false);
//
const queryParams = reactive({ const queryParams = reactive({
name: '', name: '',
}); }); //
// /** 监听分类排序模式切换 */
watch( watch(
() => isCategorySorting.value, () => isCategorySorting.value,
(newValue) => { (newValue) => {
@ -129,10 +125,10 @@ async function handleCategorySortSubmit() {
// //
const ids = categoryGroup.value.map((item: any) => item.id); const ids = categoryGroup.value.map((item: any) => item.id);
await updateCategorySortBatch(ids); await updateCategorySortBatch(ids);
message.success('分类排序成功');
} finally { } finally {
saveSortLoading.value = false; saveSortLoading.value = false;
} }
message.success('分类排序成功');
isCategorySorting.value = false; isCategorySorting.value = false;
// //
await getList(); await getList();

View File

@ -12,6 +12,7 @@ import { IconifyIcon } from '@vben/icons';
import { useUserStore } from '@vben/stores'; import { useUserStore } from '@vben/stores';
import { cloneDeep, formatDateTime, isEqual } from '@vben/utils'; import { cloneDeep, formatDateTime, isEqual } from '@vben/utils';
// TODO @jason使 A 使
import { useDebounceFn } from '@vueuse/core'; import { useDebounceFn } from '@vueuse/core';
import { useSortable } from '@vueuse/integrations/useSortable'; import { useSortable } from '@vueuse/integrations/useSortable';
import { import {
@ -36,11 +37,9 @@ import {
} from '#/api/bpm/model'; } from '#/api/bpm/model';
import { $t } from '#/locales'; import { $t } from '#/locales';
//
import CategoryRenameForm from '../../category/modules/rename-form.vue'; import CategoryRenameForm from '../../category/modules/rename-form.vue';
// FormCreate
import FormCreateDetail from '../../form/modules/detail.vue'; import FormCreateDetail from '../../form/modules/detail.vue';
import { useGridColumns } from './data'; import { useGridColumns } from '../data';
const props = defineProps<{ const props = defineProps<{
categoryInfo: ModelCategoryInfo; categoryInfo: ModelCategoryInfo;
@ -50,46 +49,26 @@ const props = defineProps<{
const emit = defineEmits(['success']); const emit = defineEmits(['success']);
/** 重命名分类对话框 */
const [CategoryRenameModal, categoryRenameModalApi] = useVbenModal({ const [CategoryRenameModal, categoryRenameModalApi] = useVbenModal({
connectedComponent: CategoryRenameForm, connectedComponent: CategoryRenameForm,
destroyOnClose: true, destroyOnClose: true,
}); });
/** 流程表单详情对话框 */
const [FormCreateDetailModal, formCreateDetailModalApi] = useVbenModal({ const [FormCreateDetailModal, formCreateDetailModalApi] = useVbenModal({
connectedComponent: FormCreateDetail, connectedComponent: FormCreateDetail,
destroyOnClose: true, destroyOnClose: true,
}); });
const router = useRouter(); const router = useRouter();
// Id const userId = useUserStore().userInfo?.id;
const userStore = useUserStore();
const userId = userStore.userInfo?.id;
const isModelSorting = ref(false); const isModelSorting = ref(false);
const originalData = ref<BpmModelApi.Model[]>([]); const originalData = ref<BpmModelApi.Model[]>([]);
const modelList = ref<BpmModelApi.Model[]>([]); const modelList = ref<BpmModelApi.Model[]>([]);
// , // TODO @jason
const isExpand = ref(props.isFirst); const isExpand = ref(props.isFirst); // ,
const [Grid, gridApi] = useVbenVxeGrid({ const sortableInstance = ref<any>(null); // 便
gridOptions: {
columns: useGridColumns(),
pagerConfig: {
enabled: false,
},
data: modelList.value,
rowConfig: {
keyField: 'id',
},
toolbarConfig: {
enabled: false, //
},
} as VxeTableGridOptions,
});
// 便
const sortableInstance = ref<any>(null);
/** 解决 v-model 问题,使用计算属性 */ /** 解决 v-model 问题,使用计算属性 */
const expandKeys = computed(() => (isExpand.value ? ['1'] : [])); const expandKeys = computed(() => (isExpand.value ? ['1'] : []));
@ -105,6 +84,24 @@ const hasPermiDeploy = computed(() => {
return hasAccessByCodes(['bpm:model:deploy']); return hasAccessByCodes(['bpm:model:deploy']);
}); });
const [Grid, gridApi] = useVbenVxeGrid({
gridOptions: {
columns: useGridColumns(),
data: modelList.value,
keepSource: true,
pagerConfig: {
enabled: false,
},
rowConfig: {
keyField: 'id',
isHover: true,
},
toolbarConfig: {
enabled: false,
},
} as VxeTableGridOptions,
});
/** 处理模型的排序 */ /** 处理模型的排序 */
function handleModelSort() { function handleModelSort() {
// //
@ -126,7 +123,6 @@ function handleModelSort() {
// //
sortableInstance.value.option('disabled', false); sortableInstance.value.option('disabled', false);
} else { } else {
const sortableClass = `.category-${props.categoryInfo.id} .vxe-table .vxe-table--body-wrapper:not(.fixed-right--wrapper) .vxe-table--body tbody`;
// 使 // 使
modelList.value = cloneDeep(props.categoryInfo.modelList); modelList.value = cloneDeep(props.categoryInfo.modelList);
// //
@ -134,26 +130,31 @@ function handleModelSort() {
data: modelList.value, data: modelList.value,
}); });
sortableInstance.value = useSortable(sortableClass, modelList.value, { sortableInstance.value = useSortable(
draggable: '.vxe-body--row', `.category-${props.categoryInfo.id} .vxe-table .vxe-table--body-wrapper:not(.fixed-right--wrapper) .vxe-table--body tbody`,
animation: 150, modelList.value,
handle: '.drag-handle', {
disabled: false, draggable: '.vxe-body--row',
onEnd: ({ newDraggableIndex, oldDraggableIndex }) => { animation: 150,
if (oldDraggableIndex !== newDraggableIndex) { handle: '.drag-handle',
modelList.value.splice( disabled: false,
newDraggableIndex ?? 0, onEnd: ({ newDraggableIndex, oldDraggableIndex }) => {
0, if (oldDraggableIndex !== newDraggableIndex) {
modelList.value.splice(oldDraggableIndex ?? 0, 1)[0]!, modelList.value.splice(
); newDraggableIndex ?? 0,
} 0,
modelList.value.splice(oldDraggableIndex ?? 0, 1)[0]!,
);
}
},
}, },
}); );
} }
} }
/** 处理模型的排序提交 */ /** 处理模型的排序提交 */
async function handleModelSortSubmit() { async function handleModelSortSubmit() {
// TODO @jasonloading
try { try {
// //
if (!modelList.value || modelList.value.length === 0) { if (!modelList.value || modelList.value.length === 0) {
@ -206,6 +207,7 @@ async function handleDeleteCategory() {
return; return;
} }
// TODO @jason await loading
confirm({ confirm({
content: `确定要删除[${props.categoryInfo.name}]吗?`, content: `确定要删除[${props.categoryInfo.name}]吗?`,
}).then(async () => { }).then(async () => {
@ -227,7 +229,7 @@ function handleFormDetail(row: any) {
}; };
formCreateDetailModalApi.setData(data).open(); formCreateDetailModalApi.setData(data).open();
} else { } else {
// TODO // TODO jason ok
console.warn('业务表单待实现', row); console.warn('业务表单待实现', row);
} }
} }
@ -237,6 +239,7 @@ function isManagerUser(row: any) {
return row.managerUserIds && row.managerUserIds.includes(userId); return row.managerUserIds && row.managerUserIds.includes(userId);
} }
/** 模型操作 */
async function modelOperation(type: string, id: number) { async function modelOperation(type: string, id: number) {
await router.push({ await router.push({
name: 'BpmModelUpdate', name: 'BpmModelUpdate',
@ -246,6 +249,7 @@ async function modelOperation(type: string, id: number) {
/** 发布流程 */ /** 发布流程 */
async function handleDeploy(row: any) { async function handleDeploy(row: any) {
// TODO @jason await loading
confirm({ confirm({
beforeClose: async ({ isConfirm }) => { beforeClose: async ({ isConfirm }) => {
if (!isConfirm) return; if (!isConfirm) return;
@ -300,6 +304,7 @@ function handleChangeState(row: any) {
const state = row.processDefinition.suspensionState; const state = row.processDefinition.suspensionState;
const newState = state === 1 ? 2 : 1; const newState = state === 1 ? 2 : 1;
const statusState = state === 1 ? '停用' : '启用'; const statusState = state === 1 ? '停用' : '启用';
// TODO @jason await loading
confirm({ confirm({
beforeClose: async ({ isConfirm }) => { beforeClose: async ({ isConfirm }) => {
if (!isConfirm) return; if (!isConfirm) return;
@ -318,6 +323,7 @@ function handleChangeState(row: any) {
/** 清理流程操作 */ /** 清理流程操作 */
function handleClean(row: any) { function handleClean(row: any) {
// TODO @jason await loading
confirm({ confirm({
beforeClose: async ({ isConfirm }) => { beforeClose: async ({ isConfirm }) => {
if (!isConfirm) return; if (!isConfirm) return;
@ -336,6 +342,7 @@ function handleClean(row: any) {
/** 删除流程操作 */ /** 删除流程操作 */
function handleDelete(row: any) { function handleDelete(row: any) {
// TODO @jason await loading
confirm({ confirm({
beforeClose: async ({ isConfirm }) => { beforeClose: async ({ isConfirm }) => {
if (!isConfirm) return; if (!isConfirm) return;
@ -401,10 +408,10 @@ watchEffect(() => {
} }
}); });
// /** 处理重命名成功 */
const handleRenameSuccess = () => { function handleRenameSuccess() {
emit('success'); emit('success');
}; }
</script> </script>
<template> <template>
@ -686,6 +693,7 @@ const handleRenameSuccess = () => {
</template> </template>
<style lang="scss" scoped> <style lang="scss" scoped>
// @jason tailwindcss
.category-draggable-model { .category-draggable-model {
// ant-collapse-header // ant-collapse-header
:deep(.ant-collapse-header) { :deep(.ant-collapse-header) {