2026-04-09 17:15:12 +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">
|
2026-04-13 13:38:35 +08:00
|
|
|
<a-button v-if="button.isDefault" :type="button.type" :disabled="button.code === 'add' && addDisabled" @click="buttonClick(button.code)">
|
2026-04-09 17:15:12 +08:00
|
|
|
<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>
|
2026-04-10 18:04:54 +08:00
|
|
|
<a-alert :message="yearTip" type="info" show-icon style="margin-left: 8px;" />
|
|
|
|
|
</template>
|
2026-04-09 17:15:12 +08:00
|
|
|
<template #bodyCell="{ column, record }">
|
|
|
|
|
<template v-if="column.dataIndex === 'action'">
|
|
|
|
|
<TableAction :actions="getActions(record)" />
|
|
|
|
|
</template>
|
|
|
|
|
</template>
|
|
|
|
|
</BasicTable>
|
|
|
|
|
<PlanYearDemandHdrEcModal @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('/plan/planYearDemandHdrEc/datalog');
|
|
|
|
|
import { DataLog } from '/@/components/pcitc';
|
|
|
|
|
import { ref, computed, onMounted, onUnmounted, createVNode, } from 'vue';
|
|
|
|
|
|
|
|
|
|
import { Modal } from 'ant-design-vue';
|
|
|
|
|
import { ExclamationCircleOutlined } from '@ant-design/icons-vue';
|
|
|
|
|
import { BasicTable, useTable, TableAction, ActionItem } from '/@/components/Table';
|
2026-04-13 13:38:35 +08:00
|
|
|
import { getLngPlanYearDemandHdrPage, deleteLngPlanYearDemandHdr, exportLngPlanYearDemandHdr,getPlanYearTip, checkCuPlanState, getCuMaxPlanYear} from '/@/api/plan/PlanYearDemandHdrEc';
|
2026-04-09 17:15:12 +08:00
|
|
|
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 { getLngPlanYearDemandHdr } from '/@/api/plan/PlanYearDemandHdrEc';
|
|
|
|
|
import { useModal } from '/@/components/Modal';
|
|
|
|
|
import PlanYearDemandHdrEcModal from './components/PlanYearDemandHdrEcModal.vue';
|
|
|
|
|
import { downloadByData } from '/@/utils/file/download';
|
|
|
|
|
import {formConfig, searchFormSchema, columns } from './components/config';
|
|
|
|
|
import Icon from '/@/components/Icon/index';
|
|
|
|
|
import useEventBus from '/@/hooks/event/useEventBus';
|
|
|
|
|
import { cloneDeep } from 'lodash-es';
|
2026-04-10 18:04:54 +08:00
|
|
|
import { useUserStore } from '/@/store/modules/user';
|
|
|
|
|
import { getCompDept } from '/@/api/approve/Appro';
|
2026-04-09 17:15:12 +08:00
|
|
|
const { bus, CREATE_FLOW, FLOW_PROCESSED, FORM_LIST_MODIFIED } = useEventBus();
|
2026-04-10 18:04:54 +08:00
|
|
|
const userStore = useUserStore();
|
|
|
|
|
const userInfo = userStore.getUserInfo;
|
|
|
|
|
const curCuCode = ref('')
|
|
|
|
|
const yearTip = ref()
|
2026-04-13 13:38:35 +08:00
|
|
|
const addDisabled = ref(false)
|
|
|
|
|
const cuMaxPlanYear = ref<number | null>(null)
|
2026-04-09 17:15:12 +08:00
|
|
|
|
|
|
|
|
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();
|
|
|
|
|
//所有按钮
|
|
|
|
|
const buttons = ref([{"isUse":true,"name":"新增","code":"add","icon":"ant-design:plus-outlined","isDefault":true,"type":"primary"},{"isUse":true,"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":"export","icon":"ant-design:export-outlined","isDefault":true},{"isUse":true,"name":"变更","code":"update","icon":"ant-design:edit-filled","isDefault":true},{"isUse":true,"name":"删除","code":"delete","icon":"ant-design:delete-outlined","isDefault":true},{"isUse":true,"name":"数据日志","code":"datalog","icon":"ant-design:profile-outlined","isDefault":true}]);
|
|
|
|
|
//展示在列表内的按钮
|
|
|
|
|
const actionButtons = ref<string[]>(['view', 'edit','datalog', 'copyData', 'delete', 'startwork','flowRecord', 'export', 'update',]);
|
|
|
|
|
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));
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
const btnEvent = {add : handleAdd,edit : handleEdit,refresh : handleRefresh,view : handleView,export : handleExport,update : handleUpdate,delete : handleDelete, datalog:handleDatalog}
|
|
|
|
|
|
|
|
|
|
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 [registerModal, { openModal }] = useModal();
|
|
|
|
|
const formName=currentRoute.value.meta?.title
|
|
|
|
|
const [registerTable, { reload, }] = useTable({
|
|
|
|
|
title: '' || (formName + '列表'),
|
|
|
|
|
api: getLngPlanYearDemandHdrPage,
|
|
|
|
|
rowKey: 'id',
|
|
|
|
|
columns: customConfigColums,
|
|
|
|
|
formConfig: {
|
|
|
|
|
rowProps: {
|
|
|
|
|
gutter: 16,
|
|
|
|
|
},
|
|
|
|
|
schemas: customSearchFormSchema,
|
|
|
|
|
fieldMapToTime: [],
|
|
|
|
|
showResetButton: true,
|
|
|
|
|
},
|
2026-04-13 13:38:35 +08:00
|
|
|
immediate: false,
|
2026-04-09 17:15:12 +08:00
|
|
|
beforeFetch: (params) => {
|
2026-04-10 18:04:54 +08:00
|
|
|
return { ...params, FormId: formIdComputedRef.value, PK: 'id', page: params.limit, cuCode: curCuCode.value };
|
2026-04-09 17:15:12 +08:00
|
|
|
},
|
|
|
|
|
afterFetch: (res) => {
|
|
|
|
|
tableRef.value.setToolBarWidth();
|
|
|
|
|
|
|
|
|
|
},
|
|
|
|
|
useSearchForm: true,
|
|
|
|
|
showTableSetting: true,
|
|
|
|
|
|
|
|
|
|
striped: false,
|
|
|
|
|
actionColumn: {
|
2026-04-10 18:04:54 +08:00
|
|
|
width: 180,
|
2026-04-09 17:15:12 +08:00
|
|
|
title: '操作',
|
|
|
|
|
dataIndex: 'action',
|
|
|
|
|
slots: { customRender: 'action' },
|
|
|
|
|
},
|
|
|
|
|
tableSetting: {
|
|
|
|
|
size: false,
|
|
|
|
|
setting: false,
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
function dbClickRow(record) {
|
|
|
|
|
router.push({
|
|
|
|
|
path: '/plan/PlanYearDemandHdrEc/createForm',
|
|
|
|
|
query: {
|
|
|
|
|
formPath: 'plan/PlanYearDemandHdrEc',
|
|
|
|
|
formName: '编辑'+formName,
|
|
|
|
|
formId:currentRoute.value.meta.formId,
|
|
|
|
|
id: record.id,
|
|
|
|
|
type: 'view'
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function buttonClick(code) {
|
|
|
|
|
|
|
|
|
|
btnEvent[code]();
|
|
|
|
|
}
|
|
|
|
|
function handleDatalog (record: Recordable) {
|
|
|
|
|
modalVisible.value = true
|
|
|
|
|
logId.value = record.id
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function handleAdd() {
|
|
|
|
|
if (schemaIdComputedRef.value) {
|
|
|
|
|
router.push({
|
|
|
|
|
path: '/flow/' + schemaIdComputedRef.value + '/0/createFlow'
|
|
|
|
|
});
|
|
|
|
|
} else {
|
|
|
|
|
router.push({
|
|
|
|
|
path: '/plan/PlanYearDemandHdrEc/createForm',
|
|
|
|
|
query: {
|
|
|
|
|
formPath: 'plan/PlanYearDemandHdrEc',
|
|
|
|
|
formName: '新建'+formName,
|
2026-04-10 18:04:54 +08:00
|
|
|
formId:currentRoute.value.meta.formId,
|
|
|
|
|
cuCode: curCuCode.value
|
2026-04-09 17:15:12 +08:00
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function handleEdit(record: Recordable) {
|
|
|
|
|
|
|
|
|
|
router.push({
|
|
|
|
|
path: '/plan/PlanYearDemandHdrEc/createForm',
|
|
|
|
|
query: {
|
|
|
|
|
formPath: 'plan/PlanYearDemandHdrEc',
|
|
|
|
|
formName: '编辑'+formName,
|
|
|
|
|
formId:currentRoute.value.meta.formId,
|
|
|
|
|
id: record.id,
|
|
|
|
|
type: 'edit'
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
function handleDelete(record: Recordable) {
|
|
|
|
|
deleteList([record.id]);
|
|
|
|
|
}
|
|
|
|
|
function deleteList(ids) {
|
|
|
|
|
Modal.confirm({
|
|
|
|
|
title: '提示信息',
|
|
|
|
|
icon: createVNode(ExclamationCircleOutlined),
|
|
|
|
|
content: '是否确认删除?',
|
|
|
|
|
okText: '确认',
|
|
|
|
|
cancelText: '取消',
|
|
|
|
|
onOk() {
|
|
|
|
|
deleteLngPlanYearDemandHdr(ids).then((_) => {
|
|
|
|
|
handleSuccess();
|
|
|
|
|
notification.success({
|
|
|
|
|
message: '提示',
|
|
|
|
|
description: t('删除成功!'),
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
onCancel() {},
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
function handleRefresh() {
|
|
|
|
|
reload();
|
|
|
|
|
}
|
|
|
|
|
function handleSuccess() {
|
|
|
|
|
|
|
|
|
|
reload();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function handleView(record: Recordable) {
|
|
|
|
|
|
|
|
|
|
dbClickRow(record);
|
|
|
|
|
|
|
|
|
|
}
|
2026-04-10 18:04:54 +08:00
|
|
|
function handleUpdate (record) {
|
|
|
|
|
router.push({
|
|
|
|
|
path: '/plan/PlanYearDemandHdrEc/createForm',
|
|
|
|
|
query: {
|
|
|
|
|
formPath: 'plan/PlanYearDemandHdrEc',
|
|
|
|
|
formName: '变更'+formName,
|
|
|
|
|
formId:currentRoute.value.meta.formId,
|
|
|
|
|
id: record.id,
|
|
|
|
|
type: 'update'
|
|
|
|
|
}
|
|
|
|
|
})
|
2026-04-09 17:15:12 +08:00
|
|
|
}
|
|
|
|
|
async function handleExport() {
|
|
|
|
|
const res = await exportLngPlanYearDemandHdr({ isTemplate: false });
|
|
|
|
|
downloadByData(
|
|
|
|
|
res.data,
|
|
|
|
|
'PlanYearDemandHdrEc.xlsx',
|
|
|
|
|
'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
|
|
|
|
|
);
|
|
|
|
|
}
|
2026-04-10 18:04:54 +08:00
|
|
|
onMounted(async() => {
|
|
|
|
|
const res = await getCompDept(userInfo.id)
|
|
|
|
|
curCuCode.value = res?.comp?.cuCode
|
2026-04-13 13:38:35 +08:00
|
|
|
reload({searchInfo:{'limit':1,'size':10,'page':1, cuCode: curCuCode.value}});
|
|
|
|
|
const checkRes = await checkCuPlanState(curCuCode.value)
|
|
|
|
|
addDisabled.value = (checkRes?.count ?? 0) !== 0
|
|
|
|
|
|
|
|
|
|
const maxYearRes = await getCuMaxPlanYear(curCuCode.value)
|
|
|
|
|
cuMaxPlanYear.value = maxYearRes?.planYear ? Number(maxYearRes.planYear) : null
|
2026-04-10 18:04:54 +08:00
|
|
|
|
|
|
|
|
const data = await getPlanYearTip()
|
|
|
|
|
yearTip.value = data?.msg
|
2026-04-09 17:15:12 +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[] {
|
|
|
|
|
|
2026-04-13 13:38:35 +08:00
|
|
|
let actionsList: ActionItem[] = []
|
|
|
|
|
let editBtn: ActionItem[] = []
|
|
|
|
|
let updateBtn: ActionItem[] = []
|
|
|
|
|
let viewBtn: ActionItem[] = [];
|
|
|
|
|
actionButtonConfig.value?.map((button) => {
|
|
|
|
|
if (['view', 'copyData','compare', 'datalog', 'export'].includes(button.code)) {
|
|
|
|
|
viewBtn.push({
|
|
|
|
|
icon: button?.icon,
|
|
|
|
|
tooltip: button?.name,
|
|
|
|
|
onClick: btnEvent[button.code].bind(null, record),
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
if (['edit','delete'].includes(button.code)) {
|
|
|
|
|
editBtn.push({
|
2026-04-09 17:15:12 +08:00
|
|
|
icon: button?.icon,
|
|
|
|
|
tooltip: button?.name,
|
2026-04-13 13:38:35 +08:00
|
|
|
onClick: btnEvent[button.code].bind(null, record),
|
2026-04-09 17:15:12 +08:00
|
|
|
color: button.code === 'delete' ? 'error' : undefined,
|
2026-04-13 13:38:35 +08:00
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
if (['update'].includes(button.code)) {
|
|
|
|
|
updateBtn.push({
|
|
|
|
|
icon: button?.icon,
|
|
|
|
|
tooltip: button?.name,
|
2026-04-09 17:15:12 +08:00
|
|
|
onClick: btnEvent[button.code].bind(null, record),
|
2026-04-13 13:38:35 +08:00
|
|
|
});
|
2026-04-09 17:15:12 +08:00
|
|
|
}
|
|
|
|
|
});
|
2026-04-13 13:38:35 +08:00
|
|
|
if (record.approCode == 'WTJ' || record.approCode == 'YBH') {
|
|
|
|
|
actionsList = actionsList.concat(editBtn);
|
|
|
|
|
}
|
|
|
|
|
const curYear = new Date().getFullYear();
|
|
|
|
|
const planYear = Number(record.planYear);
|
|
|
|
|
const canUpdate = cuMaxPlanYear.value !== null && planYear === cuMaxPlanYear.value && planYear >= curYear && record.approCode === 'YTJ' && record.lastSign === 'Y';
|
|
|
|
|
if (canUpdate) {
|
|
|
|
|
actionsList = actionsList.concat(updateBtn);
|
|
|
|
|
}
|
|
|
|
|
actionsList = actionsList.concat(viewBtn);
|
2026-04-09 17:15:12 +08:00
|
|
|
return actionsList;
|
|
|
|
|
}
|
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
</style>
|