Files
geg-gas-web/src/views/dayPlan/PngAppro/index.vue

471 lines
16 KiB
Vue
Raw Normal View History

2026-01-13 17:15:20 +08:00
<template>
<PageWrapper dense fixedHeight contentFullHeight contentClass="flex">
<BasicTable @register="registerTable" ref="tableRef" @row-dbClick="dbClickRow">
<template #toolbar>
<template v-for="button in tableButtonConfig" :key="button.code">
<a-button v-if="button.isDefault" :type="button.type" @click="buttonClick(button.code)">
<template #icon><Icon :icon="button.icon" /></template>
{{ button.name }}
</a-button>
<a-button v-else :type="button.type">
<template #icon><Icon :icon="button.icon" /></template>
{{ button.name }}
</a-button>
</template>
</template>
<template #bodyCell="{ column, record }">
2026-01-14 17:44:36 +08:00
<template v-if="column.dataIndex === 'approName'">
2026-01-16 17:28:00 +08:00
<a @click="btnCheck(record)">{{ record.approName }}</a>
2026-01-14 17:44:36 +08:00
</template>
2026-01-13 17:15:20 +08:00
<template v-if="column.dataIndex === 'action'">
<TableAction :actions="getActions(record)" />
</template>
</template>
</BasicTable>
<PngApproModal @register="registerModal" @success="handleSuccess" />
<DataLog :logId="logId" :logPath="logPath" v-model:visible="modalVisible"/>
2026-01-14 17:44:36 +08:00
<approStatusModal @register="registerApproStatus" ></approStatusModal>
2026-01-13 17:15:20 +08:00
</PageWrapper>
</template>
<script lang="ts" setup>
const modalVisible = ref(false);
const logId = ref('')
const logPath = ref('/dayPlan/pngAppro/datalog');
import { DataLog } from '/@/components/pcitc';
2026-01-14 17:44:36 +08:00
import { ref, computed, onMounted, onUnmounted, } from 'vue';
2026-01-13 17:15:20 +08:00
import { BasicTable, useTable, TableAction, ActionItem } from '/@/components/Table';
import { getLngPngApproPage, deleteLngPngAppro} from '/@/api/dayPlan/PngAppro';
import { PageWrapper } from '/@/components/Page';
import { useMessage } from '/@/hooks/web/useMessage';
import { useI18n } from '/@/hooks/web/useI18n';
import { usePermission } from '/@/hooks/web/usePermission';
import { useFormConfig } from '/@/hooks/web/useFormConfig';
import { useRouter } from 'vue-router';
import { setIndexFlowStatus } from '/@/utils/flow/index'
2026-01-20 17:32:35 +08:00
import { getLngPngAppro,getLngPngApproPageGd, getLngPngApproPageJsz, approveLngPngApproSZ, approveLngPngApproGD, approveLngPngAppro
} from '/@/api/dayPlan/PngAppro';
2026-01-13 17:15:20 +08:00
import { useModal,BasicModal } from '/@/components/Modal';
import LookProcess from '/@/views/workflow/task/components/LookProcess.vue';
import LaunchProcess from '/@/views/workflow/task/components/LaunchProcess.vue';
import ApprovalProcess from '/@/views/workflow/task/components/ApprovalProcess.vue';
import { getDraftInfo } from '/@/api/workflow/process';
import { isValidJSON } from '/@/utils/event/design';
import PngApproModal from './components/PngApproModal.vue';
import {formConfig, searchFormSchema, columns } from './components/config';
import Icon from '/@/components/Icon/index';
import FlowRecord from '/@/views/workflow/task/components/flow/FlowRecord.vue';
2026-01-14 17:44:36 +08:00
import approStatusModal from '/@/components/common/approStatusModal.vue';
2026-01-13 17:15:20 +08:00
import useEventBus from '/@/hooks/event/useEventBus';
import { cloneDeep } from 'lodash-es';
2026-01-16 17:28:00 +08:00
2026-01-13 17:15:20 +08:00
const { bus, CREATE_FLOW, FLOW_PROCESSED, FORM_LIST_MODIFIED } = useEventBus();
const { notification } = useMessage();
const { t } = useI18n();
defineEmits(['register']);
const { filterColumnAuth, filterButtonAuth } = usePermission();
const { mergeColumns,mergeSearchFormSchema,mergeButtons } = useFormConfig();
const filterColumns = cloneDeep(filterColumnAuth(columns));
const customConfigColums =ref(filterColumns);
const customSearchFormSchema =ref(searchFormSchema);
const tableRef = ref();
//所有按钮
2026-01-14 17:44:36 +08:00
const buttons = ref([{"isUse":true,"name":"查看","code":"view","icon":"ant-design:eye-outlined","isDefault":true},{"isUse":true,"name":"发起审批","code":"startwork","icon":"ant-design:form-outlined","isDefault":true},{"isUse":true,"name":"查看流转记录","code":"flowRecord","icon":"ant-design:form-outlined","isDefault":true},{"isUse":true,"name":"审批","code":"approve","icon":"ant-design:check-outlined","isDefault":true},{"isUse":true,"name":"对比","code":"compare","icon":"ant-design:file-done-outlined","isDefault":false},{"isUse":true,"name":"审批通过","code":"batchapprove","icon":"ant-design:check-outlined","isDefault":true},{"isUse":true,"name":"刷新","code":"refresh","icon":"ant-design:reload-outlined","isDefault":true}]);
2026-01-13 17:15:20 +08:00
//展示在列表内的按钮
const actionButtons = ref<string[]>(['view', 'edit','datalog', 'copyData', 'delete', 'startwork','flowRecord','approve','compare']);
const buttonConfigs = computed(()=>{
return filterButtonAuth(buttons.value);
})
const tableButtonConfig = computed(() => {
return buttonConfigs.value?.filter((x) => !actionButtons.value.includes(x.code));
});
const actionButtonConfig = computed(() => {
return buttonConfigs.value?.filter((x) => actionButtons.value.includes(x.code));
});
2026-01-14 17:44:36 +08:00
const btnEvent = {refresh : handleRefresh,view : handleView,startwork : handleStartwork,flowRecord : handleFlowRecord,approve : handleApprove,compare: handleCompare,batchapprove: handleBatchApprove}
2026-01-13 17:15:20 +08:00
const { currentRoute } = useRouter();
const router = useRouter();
2026-01-16 17:28:00 +08:00
const path = currentRoute.value?.path
2026-01-13 17:15:20 +08:00
const formIdComputedRef = ref();
formIdComputedRef.value = currentRoute.value.meta.formId
const schemaIdComputedRef = ref();
schemaIdComputedRef.value = currentRoute.value.meta.schemaId
const visibleLookProcessRef = ref(false);
const processIdRef = ref('');
const visibleLaunchProcessRef = ref(false);
const schemaIdRef = ref('');
const formDataRef = ref();
const rowKeyData = ref();
const draftsId = ref();
2026-01-20 17:32:35 +08:00
const selectedKeys = ref([])
2026-01-13 17:15:20 +08:00
const visibleApproveProcessRef = ref(false);
const taskIdRef = ref('');
const visibleFlowRecordModal = ref(false);
const [registerModal, { openModal}] = useModal();
2026-01-14 17:44:36 +08:00
const [registerApproStatus, { openModal: openModalApproStatus}] = useModal();
2026-01-16 17:28:00 +08:00
let formName='管道气销售审批';
let curPath = 'dayPlan/PngAppro/index'
2026-01-14 17:44:36 +08:00
const [registerTable, { reload, clearSelectedRowKeys, setTableData }] = useTable({
2026-01-13 17:15:20 +08:00
title: '' || (formName + '列表'),
2026-01-29 13:34:08 +08:00
api: getLngPngApproPage,
2026-01-13 17:15:20 +08:00
rowKey: 'id',
columns: customConfigColums,
formConfig: {
rowProps: {
gutter: 16,
},
schemas: customSearchFormSchema,
fieldMapToTime: [['datePlan', ['startDate', 'endDate'], 'YYYY-MM-DD HH:mm:ss ', true]],
showResetButton: true,
2026-01-15 17:55:02 +08:00
submitButtonOptions: {
text: '搜索',
onClick: () => {
clearSelectedRowKeys()
},
},
resetButtonOptions: {
text: '重置',
onClick: () => {
clearSelectedRowKeys()
},
},
2026-01-13 17:15:20 +08:00
},
beforeFetch: (params) => {
2026-01-15 17:55:02 +08:00
return { ...params, FormId: formIdComputedRef.value, PK: 'id',page: params.limit};
2026-01-13 17:15:20 +08:00
},
afterFetch: (res) => {
tableRef.value.setToolBarWidth();
},
useSearchForm: true,
showTableSetting: true,
striped: false,
actionColumn: {
width: 160,
title: '操作',
dataIndex: 'action',
slots: { customRender: 'action' },
},
rowSelection: {
type: 'checkbox',
onChange: onSelectChange
},
tableSetting: {
size: false,
setting: false,
},
});
2026-01-16 17:28:00 +08:00
const btnCheck = (record)=> {
2026-01-20 17:32:35 +08:00
openModalApproStatus(true,{isUpdate: false,id:record.demandId});
2026-01-14 17:44:36 +08:00
}
2026-01-13 17:15:20 +08:00
function onSelectChange(rowKeys: string[]) {
selectedKeys.value = rowKeys;
}
function dbClickRow(record) {
if (!actionButtonConfig?.value.some(element => element.code == 'view')) {
return;
}
const { processId, taskIds, schemaId } = record.workflowData || {};
if (taskIds && taskIds.length) {
router.push({
path: '/flow/' + schemaId + '/' + (processId || '') + '/approveFlow',
query: {
taskId: taskIds[0],
formName: formName,
formId:currentRoute.value.meta.formId
}
});
} else if (schemaId && !taskIds && processId) {
router.push({
path: '/flow/' + schemaId + '/' + processId + '/approveFlow',
query: {
readonly: 1,
taskId: '',
formName: formName,
formId:currentRoute.value.meta.formId
}
});
} else {
2026-01-16 17:28:00 +08:00
router.push({
path: '/dayPlan/PngAppro/createForm',
2026-01-13 17:15:20 +08:00
query: {
2026-01-16 17:28:00 +08:00
formPath: curPath,
2026-01-13 17:15:20 +08:00
formName: formName,
2026-01-16 17:28:00 +08:00
formId:currentRoute.value.meta.formId,
id: record.id,
type: 'view'
2026-01-13 17:15:20 +08:00
}
});
2026-01-16 17:28:00 +08:00
// router.push({
// path: '/form/PngAppro/' + record.id + '/viewForm',
// query: {
// formPath: 'dayPlan/PngAppro',
// formName: formName,
// formId:currentRoute.value.meta.formId
// }
// });
2026-01-13 17:15:20 +08:00
}
}
function buttonClick(code) {
btnEvent[code]();
}
function handleDatalog (record: Recordable) {
modalVisible.value = true
logId.value = record.id
}
function handleRefresh() {
reload();
}
function handleSuccess() {
reload();
}
function handleView(record: Recordable) {
dbClickRow(record);
}
function handleApprove(record: Recordable) {
2026-01-15 17:55:02 +08:00
router.push({
path: '/dayPlan/PngAppro/createForm',
query: {
2026-01-16 17:28:00 +08:00
formPath: curPath,
2026-01-15 17:55:02 +08:00
formName: formName,
formId:currentRoute.value.meta.formId,
id: record.id
}
});
}
2026-01-13 17:15:20 +08:00
function handleCompare (record: Recordable) {
2026-01-16 17:28:00 +08:00
router.push({
path: '/dayPlan/PngAppro/createForm',
query: {
formPath: curPath,
formName: formName+'对比',
formId:currentRoute.value.meta.formId,
id: record.demandOrgId,
type: 'compare'
}
});
2026-01-13 17:15:20 +08:00
}
2026-01-20 17:32:35 +08:00
async function handleBatchApprove () {
if (!selectedKeys.value.length) {
notification.warning({
message: 'Tip',
description: t('请选择需要审批的数据'),
});
return;
}
let arr = selectedKeys.value.map(v=> {
return {
id: v
}
})
let obj = {
"result": "C",
"remark": "",
"data": arr
}
2026-01-29 13:34:08 +08:00
await approveLngPngAppro(obj)
2026-01-20 17:32:35 +08:00
handleSuccess();
notification.success({
message: 'Tip',
description: t('审批成功!'),
});
clearSelectedRowKeys()
2026-01-14 17:44:36 +08:00
2026-01-13 17:15:20 +08:00
}
onMounted(() => {
if (schemaIdComputedRef.value) {
bus.on(FLOW_PROCESSED, handleRefresh);
bus.on(CREATE_FLOW, handleRefresh);
} else {
bus.on(FORM_LIST_MODIFIED, handleRefresh);
}
// 合并渲染覆盖配置中的列表配置,包括展示字段配置、搜索字段配置、按钮配置
mergeCustomListRenderConfig();
});
onUnmounted(() => {
if (schemaIdComputedRef.value) {
bus.off(FLOW_PROCESSED, handleRefresh);
bus.off(CREATE_FLOW, handleRefresh);
} else {
bus.off(FORM_LIST_MODIFIED, handleRefresh);
}
});
function getActions(record: Recordable):ActionItem[] {
let actionsList: ActionItem[] = [];
let editAndDelBtn: ActionItem[] = [];
2026-01-15 17:55:02 +08:00
let approveBtn: ActionItem[] = [];
let compareBtn: ActionItem[] = [];
let hasFlowRecord = false;
2026-01-13 17:15:20 +08:00
actionButtonConfig.value?.map((button) => {
2026-01-15 17:55:02 +08:00
if (['view', 'copyData', 'compare'].includes(button.code)) {
2026-01-13 17:15:20 +08:00
actionsList.push({
icon: button?.icon,
tooltip: button?.name,
onClick: btnEvent[button.code].bind(null, record),
});
}
if (['edit', 'delete'].includes(button.code)) {
editAndDelBtn.push({
icon: button?.icon,
tooltip: button?.name,
color: button.code === 'delete' ? 'error' : undefined,
onClick: btnEvent[button.code].bind(null, record),
});
}
2026-01-15 17:55:02 +08:00
if (['approve'].includes(button.code)) {
approveBtn.push({
icon: button?.icon,
tooltip: button?.name,
onClick: btnEvent[button.code].bind(null, record),
});
}
2026-01-13 17:15:20 +08:00
if (button.code === 'flowRecord') hasFlowRecord = true;
});
2026-01-15 17:55:02 +08:00
if (record.approCode == 'XS') {
actionsList = actionsList.concat(approveBtn);
2026-01-13 17:15:20 +08:00
}
2026-01-15 17:55:02 +08:00
// if (record.workflowData?.enabled) {
// //与工作流有关联的表单
// if (record.workflowData.status) {
// actionsList.unshift(setIndexFlowStatus(record.workflowData))
// } else {
// actionsList = actionsList.concat(editAndDelBtn);
// }
// } else {
// if (!record.workflowData?.processId) {
// //与工作流没有关联的表单并且在当前页面新增的数据 如选择编辑、删除按钮则加上
// actionsList = actionsList.concat(editAndDelBtn);
// }
// }
2026-01-13 17:15:20 +08:00
return actionsList;
}
function handleStartwork(record: Recordable) {
const { processId, schemaId } = record.workflowData;
router.push({
path: '/flow/' + schemaId + '/' + (processId || '') + '/approveFlow',
query: {
readonly: 1,
taskId: '',
formName: formName
}
});
}
function handleFlowRecord(record: Recordable) {
if (record.workflowData) {
visibleFlowRecordModal.value = true;
processIdRef.value = record.workflowData?.processId;
}
}
async function handleLaunchProcess(record: Recordable) {
const schemaId=record.workflowData?.schemaId||schemaIdComputedRef.value;
if(schemaId){
if(record.workflowData?.draftId){
let res = await getDraftInfo(record.workflowData.draftId);
if (isValidJSON(res.formData)) {
localStorage.setItem('draftsJsonStr', res.formData);
router.push({
path: '/flow/' + schemaId + '/'+record.workflowData.draftId+'/createFlow'
});
return;
}
}
const result = await getLngPngAppro(record['id']);
const form={};
const key="form_"+schemaId+"_"+record['id'];
form[key]=result;
localStorage.setItem('formJsonStr', JSON.stringify(form));
router.push({
path: '/flow/' + schemaId + '/0/createFlow',
query: {
fromKey: key
}
});
}
}
function handleApproveProcess(record: Recordable) {
const { processId, taskIds, schemaId } = record.workflowData;
router.push({
path: '/flow/' + schemaId + '/' + processId + '/approveFlow',
query: {
taskId: taskIds[0],
formName: formName
}
});
}
function handleCloseLaunch() {
visibleLaunchProcessRef.value = false;
reload();
}
function handleCloseApproval() {
visibleApproveProcessRef.value = false;
reload();
}
async function mergeCustomListRenderConfig(){
if (formConfig.useCustomConfig) {
let formId=currentRoute.value.meta.formId;
//1.合并展示字段配置
let cols= await mergeColumns(customConfigColums.value,formId);
customConfigColums.value=cols;
//2.合并搜索字段配置
let sFormSchema= await mergeSearchFormSchema(customSearchFormSchema.value,formId);
customSearchFormSchema.value=sFormSchema;
//3.合并按钮配置
let btns= await mergeButtons(buttons.value,formId);
buttons.value=btns;
}
};
</script>
<style lang="less" scoped>
:deep(.ant-table-selection-col) {
width: 50px;
}
:deep( .ant-col-8:nth-child(1)) {
width: 320px !important;
max-width: 320px !important;;
}
:deep(.ant-col-8:nth-child(1) .ant-form-item-label) {
width: 80px !important;
}
:deep( .ant-col-8:nth-child(2)) {
width: 360px !important;
max-width: 320px !important;;
}
:deep(.ant-col-8:nth-child(2) .ant-form-item-label) {
width: 160px !important;
}
:deep(.ant-col-8:nth-child(2) .ant-form-item-label .ant-form-item-no-colon) {
width: 160px !important;
max-width: 160px !important;
}
.show{
display: flex;
}
.hide{
display: none !important;
}
</style>