MES审批复用钉钉审批设置

This commit is contained in:
geht
2026-06-10 16:57:07 +08:00
parent 617d47a3db
commit 5cb24c582d
4 changed files with 115 additions and 24 deletions

View File

@@ -1,6 +1,7 @@
<!--
全局发起审批悬浮按钮
仅在设计并发布了审批且能匹配到对应功能页路由的页面显示
钉钉审批按钮一致当前页存在 mes_xsl_ding_tpl_bind 绑定且钉钉模板启用时显示
弹窗内可选该页业务表下已发布的 MES 审批流
支持两种发起方式
1列表多选联动在列表勾选数据后点击弹窗自动带入选中单据并可批量发起
2手动选择未勾选时在弹窗内搜索选择单条单据发起
@@ -57,11 +58,12 @@
</template>
<script lang="ts" setup>
import { computed, onMounted, reactive, ref } from 'vue';
import { computed, reactive, ref, watch } from 'vue';
import { useRouter } from 'vue-router';
import { debounce } from 'lodash-es';
import { useMessage } from '/@/hooks/web/useMessage';
import { getPublishedFlows, getBizRecords, launchApproval, launchApprovalBatch } from '/@/views/approval/flow/launch.api';
import { getBindingByRoute } from '/@/views/xslmes/dingtalk/dingTplBind/dingTplBind.api';
import { useApprovalSelection } from './useApprovalSelection';
defineOptions({ name: 'ApprovalLaunchFloat' });
@@ -78,6 +80,7 @@
const bizDataId = ref<string>();
const bizTitle = ref<string>('');
const binding = ref<any>(null);
const flowList = ref<any[]>([]);
const recordList = ref<any[]>([]);
// 打开弹窗时快照的列表勾选行(批量模式数据源)
@@ -86,18 +89,10 @@
// 悬浮位置(右下角)
const floatStyle = reactive({ right: '24px', bottom: '120px' });
function normalizePath(p?: string) {
return (p || '').trim().replace(/\/+$/, '');
}
// 与钉钉审批按钮一致:按 mes_xsl_ding_tpl_bind + 路由解析是否显示
const show = computed(() => !!binding.value);
// 当前路由匹配到的已发布审批流
const matchedFlows = computed(() => {
const cur = normalizePath(currentRoute.value?.path);
if (!cur) return [];
return flowList.value.filter((f) => f.routePath && normalizePath(f.routePath) === cur);
});
const show = computed(() => matchedFlows.value.length > 0);
const matchedFlows = computed(() => flowList.value);
const flowOptions = computed(() =>
matchedFlows.value.map((f) => ({
@@ -130,15 +125,27 @@
}))
);
onMounted(loadFlows);
async function loadFlows() {
try {
flowList.value = (await getPublishedFlows()) || [];
} catch {
watch(
() => currentRoute.value?.path,
async (path) => {
binding.value = null;
flowList.value = [];
}
}
if (!path || path === '/' || path.startsWith('/login')) {
return;
}
try {
const bind = await getBindingByRoute(path);
binding.value = bind || null;
if (binding.value) {
flowList.value = (await getPublishedFlows(path)) || [];
}
} catch {
binding.value = null;
flowList.value = [];
}
},
{ immediate: true },
);
function resetSelection() {
flowId.value = undefined;
@@ -149,6 +156,10 @@
}
async function openModal() {
if (!matchedFlows.value.length) {
createMessage.warning('当前页面暂无已发布的 MES 审批流,请先在审批流设计中发布');
return;
}
visible.value = true;
resetSelection();
// 读取当前列表页的勾选行