钉钉审批功能完善、混炼示方新增是否附加料

This commit is contained in:
geht
2026-06-10 15:41:02 +08:00
parent de48bd2324
commit 39a9bd83f1
37 changed files with 2461 additions and 166 deletions

View File

@@ -22,6 +22,7 @@ enum Api {
bindFlow = '/xslmes/mesXslDingProcessTpl/bindFlow',
approvalFlowList = '/xslmes/approvalFlow/list',
previewFlowApprovers = '/xslmes/mesXslDingProcessTpl/previewFlowApprovers',
toggleStatus = '/xslmes/mesXslDingProcessTpl/toggleStatus',
}
export const getExportUrl = Api.exportXls;
@@ -45,7 +46,7 @@ export const batchDelete = (params, handleSuccess) => {
};
export const saveOrUpdate = (params, isUpdate) =>
defHttp.post({ url: isUpdate ? Api.edit : Api.save, params }, { successMessageMode: 'none' });
defHttp.post({ url: isUpdate ? Api.edit : Api.save, params }, { successMessageMode: isUpdate ? 'message' : 'none' });
/** 新增审批模板草稿(返回含 id 的完整记录) */
export const addNewTemplate = (params) =>
@@ -81,3 +82,7 @@ export const getApprovalFlowList = (params?) =>
export const previewFlowApprovers = (flowId: string) =>
defHttp.get({ url: Api.previewFlowApprovers, params: { flowId } }, { successMessageMode: 'none' });
/** 切换模板启用/停用(停用后绑定的业务页不再显示钉钉审批按钮) */
export const toggleTplStatus = (id: string) =>
defHttp.post({ url: Api.toggleStatus, params: { id } }, { joinParamsToUrl: true });

View File

@@ -105,6 +105,10 @@
<DingApprovalLaunchModal ref="launchModalRef" @success="handleLaunchSuccess" />
<!--update-end---author:GHT ---date:2026-06-03 forMESToDing审批配置手动填表发起钉钉审批-->
<!--update-begin---author:GHT ---date:20260610 forMESToDing审批配置操作列绑定审批流程-->
<BindApprovalFlowModal ref="bindFlowModalRef" @success="handleSuccess" />
<!--update-end---author:GHT ---date:20260610 forMESToDing审批配置操作列绑定审批流程-->
<!--update-begin---author:GHT ---date:2026-06-03 forMESToDing审批配置钉钉同步结果弹窗-->
<a-modal
v-model:open="syncVisible"
@@ -154,8 +158,11 @@
//update-begin---author:GHT ---date:2026-06-03 for【MESToDing审批配置】手动填表发起钉钉审批
import DingApprovalLaunchModal from './components/DingApprovalLaunchModal.vue';
//update-end---author:GHT ---date:2026-06-03 for【MESToDing审批配置】手动填表发起钉钉审批
//update-begin---author:GHT ---date:20260610 for【MESToDing审批配置】操作列绑定审批流程
import BindApprovalFlowModal from './components/BindApprovalFlowModal.vue';
//update-end---author:GHT ---date:20260610 for【MESToDing审批配置】操作列绑定审批流程
import { columns, searchFormSchema, superQuerySchema } from './MesXslDingProcessTpl.data';
import { list, deleteOne, batchDelete, getImportUrl, getExportUrl, syncFromDingtalk, batchImport, getTemplateDetail } from './MesXslDingProcessTpl.api';
import { list, deleteOne, batchDelete, getImportUrl, getExportUrl, syncFromDingtalk, batchImport, getTemplateDetail, toggleTplStatus } from './MesXslDingProcessTpl.api';
const { createMessage } = useMessage();
const queryParam = reactive<any>({});
@@ -167,6 +174,9 @@
api: list,
columns,
canResize: true,
//update-begin---author:GHT ---date:2026-06-10 for【钉钉审批模板】操作列加宽避免按钮挤压-----------
scroll: { x: 1700 },
//update-end---author:GHT ---date:2026-06-10 for【钉钉审批模板】操作列加宽避免按钮挤压-----------
formConfig: {
schemas: searchFormSchema,
autoSubmitOnEnter: true,
@@ -175,7 +185,9 @@
actionColumn: {
title: '操作',
dataIndex: 'action',
width: 220,
//update-begin---author:GHT ---date:2026-06-10 for【钉钉审批模板】操作列加宽避免按钮挤压-----------
width: 540,
//update-end---author:GHT ---date:2026-06-10 for【钉钉审批模板】操作列加宽避免按钮挤压-----------
fixed: 'right',
slots: { customRender: 'action' },
},
@@ -230,27 +242,72 @@
(selectedRowKeys.value = []) && reload();
}
function isTplEnabled(record: Recordable) {
return record.status === '1' || record.status === 1;
}
async function handleToggleStatus(record: Recordable) {
try {
const msg = await toggleTplStatus(record.id);
createMessage.success(typeof msg === 'string' ? msg : isTplEnabled(record) ? '已停用' : '已启用');
reload();
} catch (e: any) {
createMessage.error(e?.message || '操作失败');
}
}
function getTableAction(record) {
const enabled = isTplEnabled(record);
return [
{ label: '编辑', onClick: handleEdit.bind(null, record), auth: 'xslmes:mes_xsl_ding_process_tpl:edit' },
//update-begin---author:GHT ---date:2026-06-03 forMESToDing审批配置】操作列新增发起审批按钮
//update-begin---author:GHT ---date:20260610 for钉钉审批模板】操作列停用/启用-----------
{
label: '发起审批',
label: enabled ? '停用' : '启用',
color: enabled ? 'warning' : 'success',
auth: 'xslmes:mes_xsl_ding_process_tpl:edit',
popConfirm: {
title: enabled
? '停用后,已绑定该模板的业务页面将不再显示「钉钉审批」按钮,确认停用?'
: '确认启用该审批模板?启用后业务页将恢复显示钉钉审批按钮。',
confirm: handleToggleStatus.bind(null, record),
placement: 'topLeft',
},
},
//update-end---author:GHT ---date:20260610 for【钉钉审批模板】操作列停用/启用-----------
//update-begin---author:GHT ---date:20260610 for【MESToDing审批配置】操作列绑定审批流程
{
label: '绑定审批流程',
icon: 'ant-design:apartment-outlined',
auth: 'xslmes:mes_xsl_ding_process_tpl:edit',
onClick: handleBindApprovalFlow.bind(null, record),
},
//update-end---author:GHT ---date:20260610 for【MESToDing审批配置】操作列绑定审批流程
//update-begin---author:GHT ---date:2026-06-10 for【MESToDing审批配置】设计模板移至操作列、发起审批改名为测试审批
{
label: '设计模板',
icon: 'ant-design:layout-outlined',
auth: 'xslmes:mes_xsl_ding_process_tpl:edit',
onClick: handleDesignTemplate.bind(null, record),
},
{
label: '测试审批',
icon: 'ant-design:send-outlined',
color: 'success',
disabled: !record.processCode,
tooltip: record.processCode ? '手动填表后发起钉钉审批' : '请先配置 processCode',
disabled: !enabled || !record.processCode,
tooltip: !enabled
? '模板已停用'
: record.processCode
? '手动填表后测试发起钉钉审批'
: '请先配置 processCode',
onClick: handleLaunchApproval.bind(null, record),
},
//update-end---author:GHT ---date:2026-06-03 for【MESToDing审批配置】操作列新增发起审批按钮
//update-end---author:GHT ---date:2026-06-10 for【MESToDing审批配置】设计模板移至操作列发起审批改名为测试审批
];
}
function getDropDownAction(record) {
const actions: any[] = [
{ label: '详情', onClick: handleDetail.bind(null, record) },
//update-begin---author:GHT ---date:2026-06-03 for【MESToDing审批配置】新增设计模板入口
{ label: '设计模板', onClick: handleDesignTemplate.bind(null, record), icon: 'ant-design:layout-outlined' },
];
if (!record.processCode) {
actions.push({
@@ -262,7 +319,6 @@
}
actions.push(
{ label: '查看钉钉字段', onClick: handleShowDingSchema.bind(null, record), icon: 'ant-design:dingtalk-outlined' },
//update-end---author:GHT ---date:2026-06-03 for【MESToDing审批配置】新增设计模板入口
{
label: '删除',
popConfirm: { title: '是否确认删除', confirm: handleDelete.bind(null, record), placement: 'topLeft' },
@@ -272,11 +328,24 @@
return actions;
}
// ===== 绑定审批流程 =====
//update-begin---author:GHT ---date:20260610 for【MESToDing审批配置】操作列绑定审批流程
const bindFlowModalRef = ref();
function handleBindApprovalFlow(record: Recordable) {
bindFlowModalRef.value?.open(record);
}
//update-end---author:GHT ---date:20260610 for【MESToDing审批配置】操作列绑定审批流程
// ===== 手动填表发起钉钉审批 =====
//update-begin---author:GHT ---date:2026-06-03 for【MESToDing审批配置】手动填表发起钉钉审批
const launchModalRef = ref();
function handleLaunchApproval(record: Recordable) {
if (!isTplEnabled(record)) {
createMessage.warning('该模板已停用,请先启用后再发起审批');
return;
}
if (!record.processCode) {
createMessage.warning('该模板尚未配置 processCode请先完成模板配置');
return;

View File

@@ -0,0 +1,433 @@
<!--
钉钉审批模板 - 绑定 MES 审批流弹窗
@author GHT
@date 2026-06-10 forMESToDing审批配置操作列绑定审批流程
-->
<template>
<a-modal
v-model:open="visible"
title="绑定审批流程"
width="660px"
wrap-class-name="baf-modal-wrap"
:body-style="{ padding: '8px 28px 20px' }"
:confirm-loading="submitting"
ok-text="确认绑定"
cancel-text="取消"
destroy-on-close
@ok="handleSubmit"
@cancel="handleClose"
>
<a-spin :spinning="loading">
<div class="baf-body">
<div v-if="tplRecord" class="baf-info-card">
<a-descriptions :column="1" bordered size="small" class="baf-descriptions">
<a-descriptions-item label="模板名称">{{ tplRecord.tplName || '—' }}</a-descriptions-item>
<a-descriptions-item label="processCode">
<a-typography-text v-if="tplRecord.processCode" code copyable>{{ tplRecord.processCode }}</a-typography-text>
<a-tag v-else color="orange">未创建</a-tag>
</a-descriptions-item>
<a-descriptions-item label="当前绑定">
<span v-if="currentFlowName" class="baf-bound-name">{{ currentFlowName }}</span>
<span v-else class="baf-unbound">未绑定</span>
</a-descriptions-item>
</a-descriptions>
</div>
<div class="baf-section">
<a-form layout="vertical" class="baf-form">
<a-form-item label="选择审批流程" required>
<div class="baf-select-row">
<a-select
v-model:value="selectedFlowId"
class="baf-flow-select"
placeholder="请选择 MES 审批流"
:loading="flowLoading"
:options="flowSelectOptions"
show-search
:filter-option="filterFlowOption"
allow-clear
@change="handleFlowChange"
>
<template #option="{ label, status, remark, bizTableName }">
<div class="baf-opt-item">
<span class="baf-opt-name">{{ label }}</span>
<span class="baf-opt-meta">
<span v-if="bizTableName" class="baf-opt-remark">{{ bizTableName }}</span>
<span v-if="remark" class="baf-opt-remark">{{ remark }}</span>
<a-tag
:color="status === '1' ? 'green' : status === '2' ? 'default' : 'orange'"
class="baf-opt-tag"
>
{{ status === '1' ? '已发布' : status === '2' ? '已停用' : '草稿' }}
</a-tag>
</span>
</div>
</template>
</a-select>
<a-button v-if="selectedFlowId" type="link" class="baf-design-btn" @click="handleDesignFlow">设计</a-button>
</div>
<div class="baf-hint">发起钉钉审批时将按所选审批流解析各节点审批人</div>
</a-form-item>
</a-form>
</div>
<div v-if="selectedFlowId" class="baf-preview-card">
<div class="baf-preview-title">
审批节点预览
<a-spin :spinning="previewLoading" size="small" />
</div>
<div v-if="!previewLoading && approverPreview.length === 0" class="baf-preview-empty">
该审批流暂无审批人节点请先在流程设计器中配置
</div>
<div v-else class="baf-preview-list">
<div v-for="(node, ni) in approverPreview" :key="node.nodeId || ni" class="baf-preview-node">
<a-tag :color="node.nodeType === 'cc' ? 'blue' : 'orange'" class="baf-node-tag">
{{ node.nodeType === 'cc' ? '抄送' : '审批' }}
</a-tag>
<span class="baf-preview-name">{{ node.nodeName }}</span>
<span v-if="node.users?.length" class="baf-preview-users">
{{ node.users.map((u) => u.realname || u.username).join('、') }}
</span>
</div>
</div>
<a-alert
v-if="selectedFlowStatus && selectedFlowStatus !== '1'"
type="warning"
show-icon
class="baf-warn-alert"
message="所选审批流尚未发布,发起审批前请先发布流程"
/>
</div>
</div>
</a-spin>
<FlowDesign @register="registerFlowDesign" @success="handleDesignSuccess" />
</a-modal>
</template>
<script lang="ts" setup>
import { ref, computed } from 'vue';
import { useMessage } from '/@/hooks/web/useMessage';
import { useModal } from '/@/components/Modal';
import { bindApprovalFlow, getApprovalFlowList, previewFlowApprovers } from '../MesXslDingProcessTpl.api';
import FlowDesign from '/@/views/approval/flow/components/FlowDesign.vue';
const emit = defineEmits(['success']);
const { createMessage } = useMessage();
const visible = ref(false);
const loading = ref(false);
const submitting = ref(false);
const tplRecord = ref<Recordable | null>(null);
const flowLoading = ref(false);
const flowList = ref<any[]>([]);
const selectedFlowId = ref('');
const previewLoading = ref(false);
const approverPreview = ref<any[]>([]);
const [registerFlowDesign, { openModal: openFlowDesign }] = useModal();
const flowSelectOptions = computed(() =>
flowList.value.map((f) => ({
value: f.id,
label: f.flowName,
status: f.status,
remark: f.remark || '',
bizTableName: f.bizTableName || '',
})),
);
const currentFlowName = computed(() => {
if (!tplRecord.value?.flowId) return '';
const flow = flowList.value.find((f) => f.id === tplRecord.value?.flowId);
return flow?.flowName || tplRecord.value?.flowId;
});
const selectedFlowStatus = computed(() => {
if (!selectedFlowId.value) return '';
return flowList.value.find((f) => f.id === selectedFlowId.value)?.status || '';
});
function filterFlowOption(input: string, option: any) {
return (option?.label ?? '').toLowerCase().includes(input.toLowerCase());
}
function resetState() {
selectedFlowId.value = '';
approverPreview.value = [];
tplRecord.value = null;
}
async function open(record: Recordable) {
resetState();
tplRecord.value = record;
visible.value = true;
loading.value = true;
try {
await loadFlowList();
if (record.flowId) {
selectedFlowId.value = record.flowId;
await loadPreview(record.flowId);
}
} finally {
loading.value = false;
}
}
function handleClose() {
visible.value = false;
}
async function loadFlowList() {
flowLoading.value = true;
try {
const res = await getApprovalFlowList({ pageSize: 500 });
flowList.value = res?.records || res || [];
} catch {
flowList.value = [];
} finally {
flowLoading.value = false;
}
}
async function handleFlowChange() {
approverPreview.value = [];
if (selectedFlowId.value) {
await loadPreview(selectedFlowId.value);
}
}
async function loadPreview(flowId: string) {
previewLoading.value = true;
try {
const res = await previewFlowApprovers(flowId);
approverPreview.value = Array.isArray(res) ? res : [];
} catch {
approverPreview.value = [];
} finally {
previewLoading.value = false;
}
}
function handleDesignFlow() {
const flow = flowList.value.find((f) => f.id === selectedFlowId.value);
if (flow) {
openFlowDesign(true, { record: flow, readonly: false });
}
}
async function handleDesignSuccess() {
if (selectedFlowId.value) {
await loadPreview(selectedFlowId.value);
}
}
async function handleSubmit() {
if (!tplRecord.value?.id) {
createMessage.warning('模板信息无效');
return;
}
if (!selectedFlowId.value) {
createMessage.warning('请选择要绑定的审批流程');
return;
}
submitting.value = true;
try {
await bindApprovalFlow({ id: tplRecord.value.id, flowId: selectedFlowId.value });
createMessage.success('审批流程绑定成功');
visible.value = false;
emit('success');
} catch (e: any) {
createMessage.error(e?.message || '绑定失败');
} finally {
submitting.value = false;
}
}
defineExpose({ open });
</script>
<style lang="less" scoped>
.baf-body {
padding: 4px 0;
}
.baf-info-card {
margin-bottom: 20px;
:deep(.baf-descriptions) {
border-radius: 6px;
overflow: hidden;
.ant-descriptions-item-label {
width: 110px;
background: #fafafa;
color: #666;
}
.ant-descriptions-item-content {
color: #333;
}
}
}
.baf-bound-name {
color: #1677ff;
font-weight: 500;
}
.baf-unbound {
color: #bbb;
}
.baf-section {
margin-bottom: 4px;
}
.baf-form {
:deep(.ant-form-item) {
margin-bottom: 0;
}
:deep(.ant-form-item-label > label) {
font-weight: 500;
color: #333;
}
}
.baf-select-row {
display: flex;
align-items: center;
gap: 8px;
}
.baf-flow-select {
flex: 1;
min-width: 0;
}
.baf-design-btn {
flex-shrink: 0;
padding: 0 4px;
}
.baf-hint {
margin-top: 8px;
font-size: 12px;
color: #999;
line-height: 1.6;
padding-left: 2px;
}
.baf-opt-item {
display: flex;
align-items: center;
justify-content: space-between;
gap: 8px;
}
.baf-opt-name {
flex: 1;
min-width: 0;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.baf-opt-meta {
display: flex;
align-items: center;
gap: 6px;
flex-shrink: 0;
}
.baf-opt-remark {
font-size: 11px;
color: #999;
max-width: 120px;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.baf-opt-tag {
margin: 0;
font-size: 11px;
line-height: 16px;
padding: 0 5px;
}
.baf-preview-card {
margin-top: 20px;
padding: 14px 16px;
background: #fafafa;
border: 1px solid #f0f0f0;
border-radius: 8px;
}
.baf-preview-title {
display: flex;
align-items: center;
gap: 8px;
font-size: 13px;
font-weight: 600;
color: #333;
margin-bottom: 12px;
}
.baf-preview-empty {
color: #bbb;
font-size: 12px;
padding: 8px 0;
text-align: center;
}
.baf-preview-list {
background: #fff;
border: 1px solid #f0f0f0;
border-radius: 6px;
padding: 4px 12px;
}
.baf-preview-node {
display: flex;
align-items: center;
flex-wrap: wrap;
gap: 6px;
padding: 10px 0;
border-bottom: 1px dashed #f0f0f0;
font-size: 13px;
&:last-child {
border-bottom: none;
}
}
.baf-node-tag {
margin: 0;
font-size: 11px;
}
.baf-preview-name {
font-weight: 500;
color: #333;
}
.baf-preview-users {
color: #666;
}
.baf-warn-alert {
margin-top: 12px;
border-radius: 6px;
}
</style>
<style lang="less">
.baf-modal-wrap {
.ant-modal-footer {
padding: 12px 28px 16px;
}
}
</style>

View File

@@ -676,6 +676,9 @@
try {
const detail = await getTemplateDetail(record.id);
tplData.value = detail;
if (detail?.dingNameSynced) {
createMessage.info('已从钉钉同步最新模板名称');
}
if (detail?.dingFields?.length) {
// 以钉钉最新 schema 为准(保证结构与钉钉同步)