Files
geg-gas-web/src/views/contract/ContractFact/index.vue

593 lines
20 KiB
Vue
Raw Normal View History

2025-12-24 17:38:00 +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-02-02 17:52:11 +08:00
<template v-if="column.dataIndex === 'amount'">
{{ Number.format(Number.parse(record.amount),numFormat) }}
</template>
2025-12-24 17:38:00 +08:00
<template v-if="column.dataIndex === 'action'">
<TableAction :actions="getActions(record)" />
</template>
</template>
</BasicTable>
<ContractFactModal @register="registerModal" @success="handleSuccess" />
<DataLog :logId="logId" :logPath="logPath" v-model:visible="modalVisible"/>
</PageWrapper>
</template>
<script lang="ts" setup>
const modalVisible = ref(false);
const logId = ref('')
const logPath = ref('/contract/contractFact/datalog');
import { DataLog } from '/@/components/pcitc';
2026-01-27 17:39:21 +08:00
import { ref, computed, onMounted, onUnmounted, createVNode,} from 'vue';
2025-12-24 17:38:00 +08:00
import { Modal } from 'ant-design-vue';
import { ExclamationCircleOutlined } from '@ant-design/icons-vue';
import { BasicTable, useTable, TableAction, ActionItem } from '/@/components/Table';
import { getLngContractFactPage, deleteLngContractFact} from '/@/api/contract/ContractFact';
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'
import { getLngContractFact } from '/@/api/contract/ContractFact';
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';
2026-02-04 17:59:39 +08:00
import { getAllCom } from '/@/api/contract/ContractPurInt';
2025-12-24 17:38:00 +08:00
import ContractFactModal from './components/ContractFactModal.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-02-27 17:28:41 +08:00
import dayjs from 'dayjs';
2025-12-24 17:38:00 +08:00
import useEventBus from '/@/hooks/event/useEventBus';
import { cloneDeep } from 'lodash-es';
2026-01-27 17:39:21 +08:00
import { useUserStore } from '/@/store/modules/user';
2026-02-02 17:52:11 +08:00
const numFormat = "###,###,###,###,###,###.00"
2026-01-27 17:39:21 +08:00
const userStore = useUserStore();
const userInfo = userStore.getUserInfo;
2025-12-24 17:38:00 +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-02-04 17:59:39 +08:00
const buttons = ref([{"name":"新增","code":"add","icon":"ant-design:plus-outlined","isDefault":true,"isUse":true,"type":"primary"},{"name":"编辑","code":"edit","icon":"ant-design:form-outlined","isDefault":true,"isUse":true},{"name":"刷新","code":"refresh","icon":"ant-design:reload-outlined","isDefault":true,"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":false,"isUse":true},{"name":"变更","code":"update","icon":"ant-design:edit-filled","isDefault":false,"isUse":true},{"name":"删除","code":"delete","icon":"ant-design:delete-outlined","isDefault":true,"isUse":true},{"name":"数据日志","code":"datalog","icon":"ant-design:profile-outlined","isDefault":true,"isUse":true},]);
2025-12-24 17:38:00 +08:00
//展示在列表内的按钮
2026-01-06 17:46:04 +08:00
const actionButtons = ref<string[]>(['view', 'edit','datalog', 'copyData', 'delete','update', 'startwork','flowRecord','approve']);
2025-12-24 17:38:00 +08:00
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-02-04 17:59:39 +08:00
const btnEvent = {add : handleAdd,edit : handleEdit,refresh : handleRefresh,view : handleView,startwork : handleStartwork,flowRecord : handleFlowRecord,delete : handleDelete,update: handleUpdate, approve: handleApprove,datalog : handleDatalog}
2025-12-24 17:38:00 +08:00
const { currentRoute } = useRouter();
const router = useRouter();
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();
const visibleApproveProcessRef = ref(false);
const taskIdRef = ref('');
const visibleFlowRecordModal = ref(false);
const [registerModal, { openModal }] = useModal();
2026-02-02 10:43:46 +08:00
// const formName='合同要素';
const formName=currentRoute.value.meta?.title;
2026-02-27 17:28:41 +08:00
const defaultDate = ref([dayjs().format('YYYY-MM-DD'), dayjs().format('YYYY-MM-DD')]);
const comIdList = ref([])
2025-12-24 17:38:00 +08:00
const [registerTable, { reload, }] = useTable({
title: '' || (formName + '列表'),
api: getLngContractFactPage,
rowKey: 'id',
columns: customConfigColums,
formConfig: {
rowProps: {
gutter: 16,
},
2026-02-27 17:28:41 +08:00
schemas: [
{
field: 'dateFrom',
label: '有效期',
component: 'RangePicker',
defaultValue: defaultDate.value,
componentProps: {
format: 'YYYY-MM-DD',
style: { width: '100%' },
getPopupContainer: () => document.body,
},
},
{
field: 'kName',
label: '合同号/名称',
component: 'Input',
},
{
field: 'comId',
label: '合同主体',
component: 'Select',
componentProps: {
showSearch: true,
optionFilterProp: 'label',
filterOption: (input: string, option: any) => {
return option.label.toLowerCase().indexOf(input.toLowerCase()) >= 0;
},
options: comIdList,
placeholder: '请选择',
allowClear: true,
getPopupContainer: () => document.body,
},
},
{
field: 'approCode',
label: '审批状态',
component: 'XjrSelect',
componentProps: {
datasourceType: 'dic',
params: { itemId: '1990669393069129729' },
labelField: 'name',
valueField: 'value',
getPopupContainer: () => document.body,
},
},
],
2026-02-04 17:59:39 +08:00
fieldMapToTime: [['dateFrom', ['startDate', 'endDate'], 'YYYY-MM-DD']],
2025-12-26 17:37:06 +08:00
showResetButton: true,
2025-12-24 17:38:00 +08:00
},
2026-02-27 17:28:41 +08:00
immediate: false,
2025-12-24 17:38:00 +08:00
beforeFetch: (params) => {
2026-02-02 10:43:46 +08:00
return { ...params, FormId: formIdComputedRef.value, PK: 'id',page: params.limit};
2025-12-24 17:38:00 +08:00
},
afterFetch: (res) => {
tableRef.value.setToolBarWidth();
},
useSearchForm: true,
showTableSetting: true,
striped: false,
actionColumn: {
width: 160,
title: '操作',
dataIndex: 'action',
slots: { customRender: 'action' },
},
tableSetting: {
size: false,
setting: false,
},
});
function dbClickRow(record) {
if (!actionButtonConfig?.value.some(element => element.code == 'view')) {
return;
}
2025-12-29 17:59:07 +08:00
const { processId, taskIds, schemaId, status } = record.workflowData || {};
2025-12-24 17:38:00 +08:00
if (taskIds && taskIds.length) {
router.push({
path: '/flow/' + schemaId + '/' + (processId || '') + '/approveFlow',
query: {
taskId: taskIds[0],
2026-01-30 15:55:59 +08:00
formName: "查看"+formName,
2025-12-26 17:37:06 +08:00
formId:currentRoute.value.meta.formId,
2026-01-06 17:46:04 +08:00
id: record.id,
readonly: 1,
2025-12-24 17:38:00 +08:00
}
});
} else if (schemaId && !taskIds && processId) {
router.push({
path: '/flow/' + schemaId + '/' + processId + '/approveFlow',
query: {
readonly: 1,
taskId: '',
2026-01-30 15:55:59 +08:00
formName: "查看"+formName,
2025-12-26 17:37:06 +08:00
formId:currentRoute.value.meta.formId,
2025-12-29 17:59:07 +08:00
id: record.id,
2025-12-24 17:38:00 +08:00
}
});
} else {
2025-12-26 17:37:06 +08:00
if (schemaIdComputedRef.value) {
router.push({
path: '/flow/' + schemaIdComputedRef.value + '/0/createFlow',
query: {
formPath: 'contract/ContractFact',
2026-01-30 15:55:59 +08:00
formName: "查看"+formName,
2025-12-26 17:37:06 +08:00
formId:currentRoute.value.meta.formId,
type:'edit',
id: record.id,
disabled: 1,
}
});
}
// router.push({
// path: '/form/ContractFact/' + record.id + '/viewForm',
// query: {
// formPath: 'contract/ContractFact',
// formName: formName,
// formId:currentRoute.value.meta.formId
// }
// });
2025-12-24 17:38:00 +08:00
}
}
function buttonClick(code) {
btnEvent[code]();
}
function handleDatalog (record: Recordable) {
modalVisible.value = true
logId.value = record.id
}
function handleAdd() {
if (schemaIdComputedRef.value) {
router.push({
2026-01-30 15:55:59 +08:00
path: '/flow/' + schemaIdComputedRef.value + '/0/createFlow',
query: {
formPath: 'contract/ContractFact',
formName: "新建"+formName,
}
2025-12-24 17:38:00 +08:00
});
} else {
router.push({
path: '/form/ContractFact/0/createForm',
query: {
formPath: 'contract/ContractFact',
formName: formName,
formId:currentRoute.value.meta.formId
}
});
}
}
function handleEdit(record: Recordable) {
2025-12-26 17:37:06 +08:00
if (schemaIdComputedRef.value) {
router.push({
path: '/flow/' + schemaIdComputedRef.value + '/0/createFlow',
query: {
2025-12-24 17:38:00 +08:00
formPath: 'contract/ContractFact',
2026-01-30 15:55:59 +08:00
formName: "编辑"+formName,
2025-12-26 17:37:06 +08:00
formId:currentRoute.value.meta.formId,
type:'edit',
id: record.id
}
});
} else {
router.push({
path: '/form/ContractFact/' + record.id + '/updateForm',
query: {
formPath: 'contract/ContractFact',
formName: formName,
formId:currentRoute.value.meta.formId
}
});
}
}
2026-01-06 17:46:04 +08:00
function handleUpdate(record: Recordable) {
const { processId, taskIds, schemaId } = record.workflowData || {};
if (schemaIdComputedRef.value) {
router.push({
path: '/flow/' + schemaIdComputedRef.value + '/0/createFlow',
query: {
formPath: 'contract/ContractFact',
2026-01-30 15:55:59 +08:00
formName: "变更"+formName,
2026-01-06 17:46:04 +08:00
formId:currentRoute.value.meta.formId,
type:'update',
id: record.id,
processId: processId
}
});
}
}
function handleApprove(record: Recordable) {
const { processId, taskIds, schemaId } = record.workflowData || {};
if (taskIds && taskIds.length) {
router.push({
path: '/flow/' + schemaId + '/' + (processId || '') + '/approveFlow',
query: {
taskId: taskIds[0],
2026-01-30 15:55:59 +08:00
formName: "审批"+formName,
2026-01-06 17:46:04 +08:00
formId:currentRoute.value.meta.formId,
id: record.id
}
});
}
2025-12-24 17:38:00 +08:00
}
function handleDelete(record: Recordable) {
deleteList([record.id]);
}
function deleteList(ids) {
Modal.confirm({
title: '提示信息',
icon: createVNode(ExclamationCircleOutlined),
content: '是否确认删除?',
okText: '确认',
cancelText: '取消',
onOk() {
deleteLngContractFact(ids).then((_) => {
handleSuccess();
notification.success({
message: 'Tip',
description: t('删除成功!'),
});
});
},
onCancel() {},
});
}
function handleRefresh() {
reload();
}
function handleSuccess() {
reload();
}
function handleView(record: Recordable) {
dbClickRow(record);
}
2026-02-04 17:59:39 +08:00
onMounted(async () => {
2026-02-27 17:28:41 +08:00
reload({ searchInfo: { startDate: defaultDate.value[0], endDate: defaultDate.value[1] }});
2026-02-04 17:59:39 +08:00
let res = await getAllCom() || []
2026-02-27 17:28:41 +08:00
comIdList.value = res.map(v=> {
return {
label: v.name,
value: v.id
2026-02-04 17:59:39 +08:00
}
2026-02-27 17:28:41 +08:00
})
// customSearchFormSchema.value.forEach(v => {
// if (v.field == 'comId') {
// v.componentProps.options = res.map(v=> {
// return {
// label: v.name,
// value: v.id
// }
// })
// }
// });
2025-12-24 17:38:00 +08:00
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-06 17:46:04 +08:00
let updateBtn: ActionItem[] = [];
let approveBtn: ActionItem[] = [];
let hasFlowRecord = false;
2025-12-24 17:38:00 +08:00
actionButtonConfig.value?.map((button) => {
2026-02-04 17:59:39 +08:00
if (['view', 'copyData', 'enable', 'disable', 'datalog'].includes(button.code)) {
2025-12-24 17:38:00 +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-06 17:46:04 +08:00
if (['update'].includes(button.code)) {
updateBtn.push({
icon: button?.icon,
2025-12-30 15:28:43 +08:00
tooltip: button?.name,
2026-01-06 17:46:04 +08:00
onClick: btnEvent[button.code].bind(null, record),
});
2025-12-24 17:38:00 +08:00
}
2026-01-06 17:46:04 +08:00
if (['approve'].includes(button.code)) {
approveBtn.push({
icon: button?.icon,
tooltip: button?.name,
onClick: btnEvent[button.code].bind(null, record),
});
2025-12-24 17:38:00 +08:00
}
2026-01-06 17:46:04 +08:00
if (button.code === 'flowRecord') hasFlowRecord = true;
});
// 未提交或已驳回
if (record.approCode == 'WTJ' || record.approCode == 'YBH' ) {
actionsList = actionsList.concat(editAndDelBtn);
2026-01-27 17:39:21 +08:00
if (record.createUserId !== userInfo.id) {
let idx = actionsList.findIndex(v =>v.tooltip == '删除')
idx > -1 && actionsList.splice(idx, 1)
}
2026-01-06 17:46:04 +08:00
}
// 审批中SPZ
if (record.workflowData?.editable) {
actionsList = actionsList.concat(approveBtn);
2025-12-24 17:38:00 +08:00
}
2026-01-06 17:46:04 +08:00
// 已审批
if (record.approCode == 'YSP') {
actionsList = actionsList.concat(updateBtn);
}
// 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);
// }
// }
2025-12-24 17:38:00 +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 getLngContractFact(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;
}
.show{
display: flex;
}
.hide{
display: none !important;
}
2026-02-04 17:59:39 +08:00
: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(4)) {
width: 320px !important;
max-width: 320px !important;;
}
:deep(.ant-col-8:nth-child(4) .ant-form-item-label) {
width: 80px !important;
}
:deep(.ant-col-8:nth-child(3) .ant-select-selector) {
width: 172px !important;
}
2025-12-24 17:38:00 +08:00
</style>