Files
qhmes/jeecgboot-vue3/src/views/xslmes/mesXslMixerPsCompile/MesXslMixerPsCompileList.vue

277 lines
9.0 KiB
Vue
Raw Normal View History

<template>
<div>
<BasicTable @register="registerTable" :rowSelection="rowSelection">
<template #tableTitle>
<a-button
type="primary"
v-auth="'xslmes:mes_xsl_mixer_ps_compile:add'"
@click="handleAdd"
preIcon="ant-design:plus-outlined"
>
新增
</a-button>
<a-button
v-auth="'xslmes:mes_xsl_mixer_ps_compile:proofread'"
:disabled="selectedRowKeys.length === 0"
preIcon="ant-design:check-circle-outlined"
@click="handleProofread"
>
校对
</a-button>
<a-button
v-auth="'xslmes:mes_xsl_mixer_ps_compile:audit'"
:disabled="selectedRowKeys.length === 0"
preIcon="ant-design:audit-outlined"
@click="handleAudit"
>
审核
</a-button>
<a-button
v-auth="'xslmes:mes_xsl_mixer_ps_compile:approve'"
:disabled="selectedRowKeys.length === 0"
preIcon="ant-design:safety-certificate-outlined"
@click="handleApprove"
>
批准
</a-button>
<a-button
type="primary"
v-auth="'xslmes:mes_xsl_mixer_ps_compile:exportXls'"
preIcon="ant-design:export-outlined"
@click="onExportXls"
>
导出
</a-button>
<j-upload-button
type="primary"
v-auth="'xslmes:mes_xsl_mixer_ps_compile:importExcel'"
preIcon="ant-design:import-outlined"
@click="onImportXls"
>
导入
</j-upload-button>
<a-dropdown v-if="selectedRowKeys.length > 0 && hasCompileSelection">
<template #overlay>
<a-menu>
<a-menu-item key="1" @click="batchHandleDelete">
<Icon icon="ant-design:delete-outlined" />
删除
</a-menu-item>
</a-menu>
</template>
<a-button v-auth="'xslmes:mes_xsl_mixer_ps_compile:deleteBatch'">
批量操作
<Icon icon="mdi:chevron-down" />
</a-button>
</a-dropdown>
<super-query :config="superQueryConfig" @search="handleSuperQuery" />
<!--update-begin---author:GHT ---date:2026-06-03 for钉钉PROC-GENERIC可行性验证测试按钮-->
<a-button :loading="ddTestLoading" preIcon="ant-design:dingtalk-outlined" @click="handleDdApprovalTest">
钉钉审批测试
</a-button>
<!--update-end---author:GHT ---date:2026-06-03 for钉钉PROC-GENERIC可行性验证测试按钮-->
</template>
<template #action="{ record }">
<TableAction
:actions="[
{
label: '编辑',
onClick: handleEdit.bind(null, record),
auth: 'xslmes:mes_xsl_mixer_ps_compile:edit',
ifShow: isCompileStatus(record),
},
]"
:dropDownActions="getDropDownAction(record)"
/>
</template>
</BasicTable>
<MesXslMixerPsCompileModal @register="registerModal" @success="handleSuccess" />
<!--update-begin---author:GHT ---date:2026-06-03 for钉钉PROC-GENERIC可行性验证结果弹窗-->
<a-modal v-model:open="ddTestVisible" title="钉钉审批测试结果" width="680px" :footer="null">
<a-spin :spinning="ddTestLoading">
<pre style="max-height: 520px; overflow: auto; font-size: 12px; background: #f6f8fa; padding: 14px; border-radius: 6px; white-space: pre-wrap; word-break: break-all">{{ ddTestResult }}</pre>
</a-spin>
</a-modal>
<!--update-end---author:GHT ---date:2026-06-03 for钉钉PROC-GENERIC可行性验证结果弹窗-->
</div>
</template>
<script lang="ts" name="xslmes-mesXslMixerPsCompile" setup>
import { computed, reactive, ref } from 'vue';
import { Modal } from 'ant-design-vue';
import { BasicTable, TableAction } from '/@/components/Table';
import { useModal } from '/@/components/Modal';
import { useListPage } from '/@/hooks/system/useListPage';
import { useMessage } from '/@/hooks/web/useMessage';
import Icon from '/@/components/Icon';
import MesXslMixerPsCompileModal from './components/MesXslMixerPsCompileModal.vue';
import { columns, searchFormSchema, superQuerySchema } from './MesXslMixerPsCompile.data';
import {
list,
deleteOne,
batchDelete,
getExportUrl,
getImportUrl,
proofread,
audit,
approve,
ddApprovalTest,
} from './MesXslMixerPsCompile.api';
const { createMessage } = useMessage();
const queryParam = reactive<any>({});
const [registerModal, { openModal }] = useModal();
const { tableContext, onExportXls, onImportXls } = useListPage({
tableProps: {
title: '密炼PS编制',
api: list,
columns,
canResize: true,
tableSetting: { cacheKey: 'mesXslMixerPsCompile_v20260520' },
formConfig: {
schemas: searchFormSchema,
labelWidth: 90,
autoSubmitOnEnter: true,
showAdvancedButton: true,
},
actionColumn: {
title: '操作',
dataIndex: 'action',
width: 160,
fixed: 'right',
slots: { customRender: 'action' },
},
beforeFetch: (params) => Object.assign(params, queryParam),
},
exportConfig: {
name: '密炼PS编制',
url: getExportUrl,
params: queryParam,
},
importConfig: {
url: getImportUrl,
success: handleSuccess,
},
});
const [registerTable, { reload }, { rowSelection, selectedRowKeys, selectedRows }] = tableContext;
const superQueryConfig = reactive(superQuerySchema);
const isCompileStatus = (record?: Recordable) => !record?.status || record.status === 'compile';
const hasCompileSelection = computed(
() => selectedRows.value.length > 0 && selectedRows.value.every((row) => isCompileStatus(row)),
);
function handleSuperQuery(params) {
Object.keys(params).forEach((k) => {
queryParam[k] = params[k];
});
reload();
}
function handleAdd() {
openModal(true, { isUpdate: false, showFooter: true });
}
function handleEdit(record: Recordable) {
if (record.status && record.status !== 'compile') {
createMessage.warning('仅编制状态的单据允许编辑');
return;
}
openModal(true, { record, isUpdate: true, showFooter: true });
}
function handleStatusAction(action: 'proofread' | 'audit' | 'approve', label: string) {
if (selectedRowKeys.value.length === 0) {
createMessage.warning('请先选择要' + label + '的记录');
return;
}
Modal.confirm({
title: '确认' + label,
content: `确定对选中的 ${selectedRowKeys.value.length} 条记录执行${label}吗?`,
okText: '确认',
cancelText: '取消',
onOk: async () => {
const ids = selectedRowKeys.value.join(',');
const fn = action === 'proofread' ? proofread : action === 'audit' ? audit : approve;
await fn({ ids });
createMessage.success(label + '成功');
handleSuccess();
},
});
}
function handleProofread() {
handleStatusAction('proofread', '校对');
}
function handleAudit() {
handleStatusAction('audit', '审核');
}
function handleApprove() {
handleStatusAction('approve', '批准');
}
function handleDetail(record: Recordable) {
openModal(true, { record, isUpdate: true, showFooter: false });
}
function handleDelete(record: Recordable) {
if (!isCompileStatus(record)) {
createMessage.warning('仅编制状态的单据允许删除');
return;
}
deleteOne({ id: record.id }, handleSuccess);
}
function batchHandleDelete() {
if (!hasCompileSelection.value) {
createMessage.warning('仅编制状态的单据允许删除,请取消已流转记录的勾选');
return;
}
batchDelete({ ids: selectedRowKeys.value.join(',') }, handleSuccess);
}
function handleSuccess() {
reload();
selectedRowKeys.value = [];
}
//update-begin---author:GHT ---date:2026-06-03 for【钉钉PROC-GENERIC可行性验证】测试逻辑
const ddTestVisible = ref(false);
const ddTestLoading = ref(false);
const ddTestResult = ref('');
async function handleDdApprovalTest() {
ddTestVisible.value = true;
ddTestLoading.value = true;
ddTestResult.value = '正在请求,请稍候...';
try {
const res = await ddApprovalTest();
ddTestResult.value = JSON.stringify(res, null, 2);
} catch (e: any) {
ddTestResult.value = '请求失败:\n' + (e?.message || JSON.stringify(e));
} finally {
ddTestLoading.value = false;
}
}
//update-end---author:GHT ---date:2026-06-03 for【钉钉PROC-GENERIC可行性验证】测试逻辑
function getDropDownAction(record: Recordable) {
return [
{ label: '详情', onClick: handleDetail.bind(null, record) },
{
label: '删除',
popConfirm: { title: '是否确认删除', confirm: handleDelete.bind(null, record) },
auth: 'xslmes:mes_xsl_mixer_ps_compile:delete',
ifShow: isCompileStatus(record),
},
];
}
</script>