采购计量业务

This commit is contained in:
‘huanghaiixia’
2026-03-12 16:08:51 +08:00
parent fb23a516d5
commit 1683ae2cc8
8 changed files with 2309 additions and 1 deletions

View File

@ -0,0 +1,127 @@
import { LngPngMeasureSalesPurPageModel, LngPngMeasureSalesPurPageParams, LngPngMeasureSalesPurPageResult } from './model/PngMeasurePurModel';
import { defHttp } from '/@/utils/http/axios';
import { ErrorMessageMode } from '/#/axios';
enum Api {
// Page = '/dayPlan/pngMeasurePur/page',
Page = '/magic-api/dayPlan/pngMeasurePurPageList',
List = '/dayPlan/pngMeasurePur/list',
Info = '/dayPlan/pngMeasurePur/info',
LngPngMeasureSalesPur = '/dayPlan/pngMeasurePur',
submit = '/dayPlan/pngMeasurePur/submit',
Cancel = '/dayPlan/pngMeasurePur/cancel',
Reject = '/dayPlan/pngMeasurePur/reject',
DataLog = '/dayPlan/pngMeasurePur/datalog',
}
export async function rejectLngPngMeasurePur(lngPngMeasureSalesPur: Recordable, mode: ErrorMessageMode = 'modal') {
return defHttp.post<boolean>(
{
url: Api.Reject,
params: lngPngMeasureSalesPur,
},
{
errorMessageMode: mode,
},
);
}
export async function submitLngPngMeasurePur(lngPngMeasureSalesPur: Recordable, mode: ErrorMessageMode = 'modal') {
return defHttp.post<boolean>(
{
url: Api.submit,
params: lngPngMeasureSalesPur,
},
{
errorMessageMode: mode,
},
);
}
/**
* @description: 取消LngPngMeasureSalesPur
*/
export async function cancelLngPngMeasurePur(lngPngMeasureSalesPur: Recordable, mode: ErrorMessageMode = 'modal') {
return defHttp.post<boolean>(
{
url: Api.Cancel,
params: lngPngMeasureSalesPur,
},
{
errorMessageMode: mode,
},
);
}
/**
* @description: 查询LngPngMeasureSalesPur分页列表
*/
export async function getLngPngMeasureSalesPurPage(params: LngPngMeasureSalesPurPageParams, mode: ErrorMessageMode = 'modal') {
return defHttp.get<LngPngMeasureSalesPurPageResult>(
{
url: Api.Page,
params,
},
{
errorMessageMode: mode,
},
);
}
/**
* @description: 获取LngPngMeasureSalesPur信息
*/
export async function getLngPngMeasureSalesPur(id: String, mode: ErrorMessageMode = 'modal') {
return defHttp.get<LngPngMeasureSalesPurPageModel>(
{
url: Api.Info,
params: { id },
},
{
errorMessageMode: mode,
},
);
}
/**
* @description: 新增LngPngMeasureSalesPur
*/
export async function addLngPngMeasureSalesPur(lngPngMeasureSalesPur: Recordable, mode: ErrorMessageMode = 'modal') {
return defHttp.post<boolean>(
{
url: Api.LngPngMeasureSalesPur,
params: lngPngMeasureSalesPur,
},
{
errorMessageMode: mode,
},
);
}
/**
* @description: 更新LngPngMeasureSalesPur
*/
export async function updateLngPngMeasureSalesPur(lngPngMeasureSalesPur: Recordable, mode: ErrorMessageMode = 'modal') {
return defHttp.put<boolean>(
{
url: Api.LngPngMeasureSalesPur,
params: lngPngMeasureSalesPur,
},
{
errorMessageMode: mode,
},
);
}
/**
* @description: 删除LngPngMeasureSalesPur批量删除
*/
export async function deleteLngPngMeasureSalesPur(ids: string[], mode: ErrorMessageMode = 'modal') {
return defHttp.delete<boolean>(
{
url: Api.LngPngMeasureSalesPur,
data: ids,
},
{
errorMessageMode: mode,
},
);
}

View File

@ -0,0 +1,102 @@
import { BasicPageParams, BasicFetchResult } from '/@/api/model/baseModel';
/**
* @description: LngPngMeasureSalesPur分页参数 模型
*/
export interface LngPngMeasureSalesPurPageParams extends BasicPageParams {
id: string;
datePlan: string;
dateMea: string;
cuCode: string;
pointDelyCode: string;
suCode: string;
pointUpCode: string;
qtySalesGj: string;
qtySalesM3: string;
qtyMeaGj: string;
qtyMeaM3: string;
rateM3Gj: string;
modifyDate: string;
cfmCuUserId: string;
cfmCuUserTime: string;
cfmEmpId: string;
cfmEmpTime: string;
ksId: string;
kpId: string;
salesPurId: string;
comId: string;
}
/**
* @description: LngPngMeasureSalesPur分页返回值模型
*/
export interface LngPngMeasureSalesPurPageModel {
id: string;
datePlan: string;
dateMea: string;
cuCode: string;
pointDelyCode: string;
suCode: string;
pointUpCode: string;
qtySalesGj: string;
qtySalesM3: string;
qtyMeaGj: string;
qtyMeaM3: string;
rateM3Gj: string;
modifyDate: string;
cfmCuUserId: string;
cfmCuUserTime: string;
cfmEmpId: string;
cfmEmpTime: string;
ksId: string;
kpId: string;
salesPurId: string;
comId: string;
}
0;
/**
* @description: LngPngMeasureSalesPur分页返回值结构
*/
export type LngPngMeasureSalesPurPageResult = BasicFetchResult<LngPngMeasureSalesPurPageModel>;

View File

@ -0,0 +1,224 @@
<template>
<SimpleForm
ref="systemFormRef"
:formProps="data.formDataProps"
:formModel="{}"
:isWorkFlow="props.fromPage!=FromPageType.MENU"
/>
</template>
<script lang="ts" setup>
import { reactive, ref,onBeforeMount,onMounted } from 'vue';
import { formProps, formEventConfigs ,formConfig} from './config';
import SimpleForm from '/@/components/SimpleForm/src/SimpleForm.vue';
import { addLngPngMeasureSalesPur, getLngPngMeasureSalesPur, updateLngPngMeasureSalesPur, deleteLngPngMeasureSalesPur } from '/@/api/dayPlan/PngMeasurePur';
import { cloneDeep } from 'lodash-es';
import { FormDataProps } from '/@/components/Designer/src/types';
import { usePermission } from '/@/hooks/web/usePermission';
import { useFormConfig } from '/@/hooks/web/useFormConfig';
import { FromPageType } from '/@/enums/workflowEnum';
import { createFormEvent, getFormDataEvent, loadFormEvent, submitFormEvent,} from '/@/hooks/web/useFormEvent';
import { changeWorkFlowForm, changeSchemaDisabled } from '/@/hooks/web/useWorkFlowForm';
import { WorkFlowFormParams } from '/@/model/workflow/bpmnConfig';
import { useRouter } from 'vue-router';
const { filterFormSchemaAuth } = usePermission();
const { mergeFormSchemas,mergeFormEventConfigs } = useFormConfig();
const { currentRoute } = useRouter();
const RowKey = 'id';
const emits = defineEmits(['changeUploadComponentIds','loadingCompleted', 'form-mounted']);
const props = defineProps({
fromPage: {
type: Number,
default: FromPageType.MENU,
},
});
const systemFormRef = ref();
const data: { formDataProps: FormDataProps } = reactive({
formDataProps: {schemas:[]} as FormDataProps,
});
const state = reactive({
formModel: {},
});
let customFormEventConfigs=[];
onMounted(async () => {
try {
// 合并渲染覆盖配置中的字段配置、表单事件配置
await mergeCustomFormRenderConfig();
if (props.fromPage == FromPageType.MENU) {
setMenuPermission();
await createFormEvent(customFormEventConfigs, state.formModel,
systemFormRef.value,
formProps.schemas); //表单事件:初始化表单
await loadFormEvent(customFormEventConfigs, state.formModel,
systemFormRef.value,
formProps.schemas); //表单事件:加载表单
} else if (props.fromPage == FromPageType.FLOW) {
emits('loadingCompleted'); //告诉系统表单已经加载完毕
// loadingCompleted后 工作流页面直接利用Ref调用setWorkFlowForm方法
} else if (props.fromPage == FromPageType.PREVIEW) {
// 预览 无需权限,表单事件也无需执行
} else if (props.fromPage == FromPageType.DESKTOP) {
// 桌面设计 表单事件需要执行
emits('loadingCompleted'); //告诉系统表单已经加载完毕
await createFormEvent(customFormEventConfigs, state.formModel,
systemFormRef.value,
formProps.schemas); //表单事件:初始化表单
await loadFormEvent(customFormEventConfigs, state.formModel,
systemFormRef.value,
formProps.schemas); //表单事件:加载表单
}
emits('form-mounted', formProps);
} catch (error) {
}
});
async function mergeCustomFormRenderConfig() {
let cloneProps=cloneDeep(formProps);
let fEventConfigs=cloneDeep(formEventConfigs);
if (formConfig.useCustomConfig) {
if(props.fromPage !== FromPageType.FLOW){
let formPath=currentRoute.value.query.formPath;
//1.合并字段配置
cloneProps.schemas=await mergeFormSchemas({formSchema:cloneProps.schemas!,formPath:formPath});
//2.合并表单事件配置
fEventConfigs=await mergeFormEventConfigs({formEventConfigs:fEventConfigs,formPath:formPath});
}
}
data.formDataProps=cloneProps;
customFormEventConfigs=fEventConfigs;
}
// 根据菜单页面权限,设置表单属性(必填,禁用,显示)
function setMenuPermission() {
data.formDataProps.schemas = filterFormSchemaAuth(data.formDataProps.schemas!);
}
// 校验form 通过返回表单数据
async function validate() {
let values = [];
try {
values = await systemFormRef.value?.validate();
//添加隐藏组件
if (data.formDataProps.hiddenComponent?.length) {
data.formDataProps.hiddenComponent.forEach((component) => {
values[component.bindField] = component.value;
});
}
} finally {
}
return values;
}
// 根据行唯一ID查询行数据并设置表单数据 【编辑】
async function setFormDataFromId(rowId, skipUpdate) {
try {
const record = await getLngPngMeasureSalesPur(rowId);
if (skipUpdate) {
return record;
}
setFieldsValue(record);
state.formModel = record;
await getFormDataEvent(customFormEventConfigs, state.formModel, systemFormRef.value, formProps.schemas); //表单事件:获取表单数据
return record;
} catch (error) {
}
}
// 辅助设置表单数据
function setFieldsValue(record) {
systemFormRef.value.setFieldsValue(record);
}
// 重置表单数据
async function resetFields() {
await systemFormRef.value.resetFields();
}
// 设置表单数据全部为Disabled 【查看】
async function setDisabledForm(isDisabled) {
data.formDataProps.schemas = changeSchemaDisabled(cloneDeep(data.formDataProps.schemas),isDisabled);
}
// 获取行键值
function getRowKey() {
return RowKey;
}
// 更新api表单数据
async function update({ values, rowId }) {
try {
values[RowKey] = rowId;
state.formModel = values;
let saveVal = await updateLngPngMeasureSalesPur(values);
await submitFormEvent(customFormEventConfigs, state.formModel,
systemFormRef.value,
formProps.schemas); //表单事件:提交表单
return saveVal;
} catch (error) {}
}
// 新增api表单数据
async function add(values) {
try {
state.formModel = values;
let saveVal = await addLngPngMeasureSalesPur(values);
await submitFormEvent(customFormEventConfigs, state.formModel,
systemFormRef.value,
formProps.schemas); //表单事件:提交表单
return saveVal;
} catch (error) {}
}
// 根据工作流页面权限,设置表单属性(必填,禁用,显示)
async function setWorkFlowForm(obj: WorkFlowFormParams) {
try {
const cloneProps=cloneDeep(formProps);
customFormEventConfigs=cloneDeep(formEventConfigs);
if (formConfig.useCustomConfig) {
const parts = obj.formConfigKey.split('_');
const formId=parts[1];
cloneProps.schemas=await mergeFormSchemas({formSchema:cloneProps.schemas!,formId:formId});
customFormEventConfigs=await mergeFormEventConfigs({formEventConfigs:customFormEventConfigs,formId:formId});
}
let flowData = changeWorkFlowForm(cloneProps, obj);
let { buildOptionJson, uploadComponentIds, formModels, isViewProcess } = flowData;
data.formDataProps = buildOptionJson;
emits('changeUploadComponentIds', uploadComponentIds); //工作流中必须保存上传组件id【附件汇总需要】
if (isViewProcess) {
setDisabledForm(); //查看
}
state.formModel = formModels;
if(formModels[RowKey]) {
setFormDataFromId(formModels[RowKey], false)
} else {
setFieldsValue(formModels)
}
} catch (error) {}
await createFormEvent(customFormEventConfigs, state.formModel,
systemFormRef.value,
formProps.schemas); //表单事件:初始化表单
await loadFormEvent(customFormEventConfigs, state.formModel,
systemFormRef.value,
formProps.schemas); //表单事件:加载表单
}
function getFormModel() {
return systemFormRef.value.formModel
}
async function handleDelete(id) {
return await deleteLngPngMeasureSalesPur([id]);
}
defineExpose({
setFieldsValue,
resetFields,
validate,
add,
update,
setFormDataFromId,
setDisabledForm,
setMenuPermission,
setWorkFlowForm,
getRowKey,
getFormModel,
handleDelete
});
</script>

View File

@ -0,0 +1,110 @@
<template>
<BasicModal v-bind="$attrs" @register="registerModal" :title="getTitle" @ok="handleSubmit" @cancel="handleClose" :paddingRight="15" :bodyStyle="{ minHeight: '400px !important' }">
<ModalForm ref="formRef" :fromPage="FromPageType.MENU" />
</BasicModal>
</template>
<script lang="ts" setup>
import { ref, computed, reactive } from 'vue';
import { BasicModal, useModalInner } from '/@/components/Modal';
import { useMessage } from '/@/hooks/web/useMessage';
import { useI18n } from '/@/hooks/web/useI18n';
import { formProps } from './config';
import ModalForm from './Form.vue';
import { FromPageType } from '/@/enums/workflowEnum';
const emit = defineEmits(['success', 'register']);
const { notification } = useMessage();
const formRef = ref();
const state = reactive({
formModel: {},
isUpdate: true,
isView: false,
isCopy: false,
rowId: '',
});
const { t } = useI18n();
const [registerModal, { setModalProps, closeModal }] = useModalInner(async (data) => {
state.isUpdate = !!data?.isUpdate;
state.isView = !!data?.isView;
state.isCopy = !!data?.isCopy;
setModalProps({
destroyOnClose: true,
maskClosable: false,
showCancelBtn: !state.isView,
showOkBtn: !state.isView,
canFullscreen: true,
width: 900,
});
if (state.isUpdate || state.isView || state.isCopy) {
state.rowId = data.id;
if (state.isView) {
await formRef.value.setDisabledForm();
}
await formRef.value.setFormDataFromId(state.rowId);
} else {
formRef.value.resetFields();
}
});
const getTitle = computed(() => (state.isView ? '查看' : !state.isUpdate ? '新增' : '编辑'));
async function saveModal() {
let saveSuccess = false;
try {
const values = await formRef.value?.validate();
//添加隐藏组件
if (formProps.hiddenComponent?.length) {
formProps.hiddenComponent.forEach((component) => {
values[component.bindField] = component.value;
});
}
if (values !== false) {
try {
if (!state.isUpdate || state.isCopy) {
saveSuccess = await formRef.value.add(values);
} else {
saveSuccess = await formRef.value.update({ values, rowId: state.rowId });
}
return saveSuccess;
} catch (error) {}
}
} catch (error) {
return saveSuccess;
}
}
async function handleSubmit() {
try {
const saveSuccess = await saveModal();
setModalProps({ confirmLoading: true });
if (saveSuccess) {
if (!state.isUpdate || state.isCopy) {
//false 新增
notification.success({
message: 'Tip',
description: t('新增成功!'),
}); //提示消息
} else {
notification.success({
message: 'Tip',
description: t('修改成功!'),
}); //提示消息
}
closeModal();
formRef.value.resetFields();
emit('success');
}
} finally {
setModalProps({ confirmLoading: false });
}
}
function handleClose() {
formRef.value.resetFields();
}
</script>

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,317 @@
export const permissionList = [
{
required: true,
view: true,
edit: true,
disabled: false,
isSaveTable: false,
tableName: '',
fieldName: 'id',
fieldId: 'id',
isSubTable: false,
showChildren: true,
type: 'input',
key: 'c910ef241351491ea24b9ec3dff5b962',
children: [],
},
{
required: true,
view: true,
edit: true,
disabled: false,
isSaveTable: false,
tableName: '',
fieldName: '计划日期',
fieldId: 'datePlan',
isSubTable: false,
showChildren: true,
type: 'input',
key: 'faa288d9a1374c148c1c894004677b35',
children: [],
},
{
required: true,
view: true,
edit: true,
disabled: false,
isSaveTable: false,
tableName: '',
fieldName: '计量日期',
fieldId: 'dateMea',
isSubTable: false,
showChildren: true,
type: 'input',
key: 'fa41d78b28654247b230764ad8bfc521',
children: [],
},
{
required: true,
view: true,
edit: true,
disabled: false,
isSaveTable: false,
tableName: '',
fieldName: '客户',
fieldId: 'cuCode',
isSubTable: false,
showChildren: true,
type: 'input',
key: '8521e888da2d41ebb7751a3b001604c6',
children: [],
},
{
required: true,
view: true,
edit: true,
disabled: false,
isSaveTable: false,
tableName: '',
fieldName: '下载点',
fieldId: 'pointDelyCode',
isSubTable: false,
showChildren: true,
type: 'input',
key: '81623a1d60454d158e484e3858f7e56a',
children: [],
},
{
required: true,
view: true,
edit: true,
disabled: false,
isSaveTable: false,
tableName: '',
fieldName: '供应商',
fieldId: 'suCode',
isSubTable: false,
showChildren: true,
type: 'input',
key: '52b7f27315704165a697b29f26e398f1',
children: [],
},
{
required: true,
view: true,
edit: true,
disabled: false,
isSaveTable: false,
tableName: '',
fieldName: '上载点',
fieldId: 'pointUpCode',
isSubTable: false,
showChildren: true,
type: 'input',
key: '95b7261c537e478f8d9d27a57c3da878',
children: [],
},
{
required: true,
view: true,
edit: true,
disabled: false,
isSaveTable: false,
tableName: '',
fieldName: '批复量 (吉焦)',
fieldId: 'qtySalesGj',
isSubTable: false,
showChildren: true,
type: 'input',
key: 'f52ab7c25c3548a1a0e8b5acbfd10692',
children: [],
},
{
required: true,
view: true,
edit: true,
disabled: false,
isSaveTable: false,
tableName: '',
fieldName: '批复量 (方)',
fieldId: 'qtySalesM3',
isSubTable: false,
showChildren: true,
type: 'input',
key: 'cc30102240434c61adeb45a9d04ba0cd',
children: [],
},
{
required: true,
view: true,
edit: true,
disabled: false,
isSaveTable: false,
tableName: '',
fieldName: '完成量 (吉焦)',
fieldId: 'qtyMeaGj',
isSubTable: false,
showChildren: true,
type: 'input',
key: '0bd6106c5273403296dbea6b6110cfe1',
children: [],
},
{
required: true,
view: true,
edit: true,
disabled: false,
isSaveTable: false,
tableName: '',
fieldName: '完成量 (方)',
fieldId: 'qtyMeaM3',
isSubTable: false,
showChildren: true,
type: 'input',
key: '975abc1b3ab142298c0a3177fb104b44',
children: [],
},
{
required: true,
view: true,
edit: true,
disabled: false,
isSaveTable: false,
tableName: '',
fieldName: '比值 (方/吉焦)',
fieldId: 'rateM3Gj',
isSubTable: false,
showChildren: true,
type: 'input',
key: 'dadec2e649074a539771a661c3cbec90',
children: [],
},
{
required: true,
view: true,
edit: true,
disabled: false,
isSaveTable: false,
tableName: '',
fieldName: '附件',
fieldId: 'modifyDate',
isSubTable: false,
showChildren: true,
type: 'input',
key: '7adebb1d02b449248b8f1f76e0227eaf',
children: [],
},
{
required: true,
view: true,
edit: true,
disabled: false,
isSaveTable: false,
tableName: '',
fieldName: '客户确认人',
fieldId: 'cfmCuUserId',
isSubTable: false,
showChildren: true,
type: 'input',
key: '04bfdc91e3aa45659defa2704fdbdf93',
children: [],
},
{
required: true,
view: true,
edit: true,
disabled: false,
isSaveTable: false,
tableName: '',
fieldName: '客户确认时间',
fieldId: 'cfmCuUserTime',
isSubTable: false,
showChildren: true,
type: 'input',
key: 'c9db7957b454491a9c89ea8a83697d36',
children: [],
},
{
required: true,
view: true,
edit: true,
disabled: false,
isSaveTable: false,
tableName: '',
fieldName: '内部确认人',
fieldId: 'cfmEmpId',
isSubTable: false,
showChildren: true,
type: 'input',
key: 'ec851f8e853d485d98e418413b2f19b7',
children: [],
},
{
required: true,
view: true,
edit: true,
disabled: false,
isSaveTable: false,
tableName: '',
fieldName: '内部确认时间',
fieldId: 'cfmEmpTime',
isSubTable: false,
showChildren: true,
type: 'input',
key: 'a5b1119bc04b46aba72d11c4a8a83bf2',
children: [],
},
{
required: true,
view: true,
edit: true,
disabled: false,
isSaveTable: false,
tableName: '',
fieldName: '销售合同',
fieldId: 'ksId',
isSubTable: false,
showChildren: true,
type: 'input',
key: '77e0ae785c7144f081edb386eee8d896',
children: [],
},
{
required: true,
view: true,
edit: true,
disabled: false,
isSaveTable: false,
tableName: '',
fieldName: '采购合同',
fieldId: 'kpId',
isSubTable: false,
showChildren: true,
type: 'input',
key: '7c8dbc9a889945f88e62076f7bd9f2c3',
children: [],
},
{
required: true,
view: true,
edit: true,
disabled: false,
isSaveTable: false,
tableName: '',
fieldName: '状态',
fieldId: 'salesPurId',
isSubTable: false,
showChildren: true,
type: 'input',
key: 'e449b13549194b669491d020a7a48018',
children: [],
},
{
required: true,
view: true,
edit: true,
disabled: false,
isSaveTable: false,
tableName: '',
fieldName: '驳回意见',
fieldId: 'comId',
isSubTable: false,
showChildren: true,
type: 'input',
key: '4009a493af0f4c8eab6290d648d9b178',
children: [],
},
];

View File

@ -0,0 +1,425 @@
<template>
<PageWrapper dense fixedHeight contentFullHeight contentClass="flex" class="PngMeasurePurStyle">
<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 }">
<template v-if="column.dataIndex === 'lngFileUploadList'">
<div v-for="(item, idx) in record.lngFileUploadList">
<a @click="handleDownload(item)">{{item.fileOrg}}</a>
</div>
</template>
<template v-if="column.dataIndex === 'action'">
<TableAction :actions="getActions(record)" />
</template>
</template>
</BasicTable>
<PngMeasurePurModal @register="registerModal" @success="handleSuccess" />
<DataLog :logId="logId" :logPath="logPath" v-model:visible="modalVisible"/>
<rejectReplyModal :visible="isOpen" @success="handleRejectReply" />
</PageWrapper>
</template>
<script lang="ts" setup>
const modalVisible = ref(false);
const logId = ref('')
const logPath = ref('/dayPlan/pngMeasurePur/datalog');
import { DataLog } from '/@/components/pcitc';
import { ref, computed, onMounted, onUnmounted, watch } from 'vue';
import { BasicTable, useTable, TableAction, ActionItem } from '/@/components/Table';
import { getLngPngMeasureSalesPurPage, deleteLngPngMeasureSalesPur,submitLngPngMeasurePur,
cancelLngPngMeasurePur, rejectLngPngMeasurePur} from '/@/api/dayPlan/PngMeasurePur';
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 { getLngPngMeasureSalesPur } from '/@/api/dayPlan/PngMeasurePur';
import { useModal } from '/@/components/Modal';
import PngMeasurePurModal from './components/PngMeasurePurModal.vue';
import {formConfig, searchFormSchema, columns } from './components/config';
import Icon from '/@/components/Icon/index';
import useEventBus from '/@/hooks/event/useEventBus';
import { cloneDeep } from 'lodash-es';
import { parseDownloadUrl} from '/@/api/system/file';
import { downloadByUrl } from '/@/utils/file/download';
import { DataFormat, FormatOption, DATE_FORMAT, FormatType } from '/@/utils/dataFormat';
import rejectReplyModal from '/@/components/common/rejectReplyModal.vue';
const { bus, CREATE_FLOW, FLOW_PROCESSED, FORM_LIST_MODIFIED } = useEventBus();
const { notification } = useMessage();
const { t } = useI18n();
const isOpen = ref(false)
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 tableData = ref([])
const selectedKeys = ref<string[]>([]);
//所有按钮
const buttons = ref([{"name":"刷新","code":"refresh","icon":"ant-design:reload-outlined","isDefault":true,"isUse":true},{"name":"数据日志","code":"datalog","icon":"ant-design:profile-outlined","isDefault":true,"isUse":true},{"name":"确认","code":"submit","icon":"ant-design:check-outlined","isDefault":false,"isUse":true},{"name":"取消确认","code":"cancel","icon":"ant-design:rollback-outlined","isDefault":false,"isUse":true},{"name":"驳回","code":"reject","icon":"ant-design:stop-outlined","isDefault":false,"isUse":true}]);
//展示在列表内的按钮
const actionButtons = ref<string[]>(['view', 'edit','datalog', 'copyData', 'delete', 'startwork','flowRecord','submit','cancel','reject']);
const buttonConfigs = computed(()=>{
return filterButtonAuth(buttons.value);
})
const tableButtonConfig = computed(() => {
let arr =[{"name":"确认","code":"submit","icon":"ant-design:check-outlined","isDefault":true,"isUse":true},{"name":"取消确认","code":"cancel","icon":"ant-design:rollback-outlined","isDefault":true,"isUse":true},{"name":"驳回","code":"reject","icon":"ant-design:stop-outlined","isDefault":true,"isUse":true},{"name":"刷新","code":"refresh","icon":"ant-design:reload-outlined","isDefault":true,"isUse":true},]
return arr
// 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 = {refresh : handleRefresh,datalog : handleDatalog,submit: handleSubmit, cancel: handleCancel, reject: handleReject}
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, setTableData,clearSelectedRowKeys }] = useTable({
title: '' || (formName + '列表'),
api: getLngPngMeasureSalesPurPage,
rowKey: 'id',
columns: customConfigColums,
formConfig: {
rowProps: {
gutter: 16,
},
schemas: customSearchFormSchema,
fieldMapToTime: [['dateMea', ['dateMeaStart', 'dateMeaEnd'], 'YYYY-MM-DD'],['datePlan', ['startDate', 'endDate'], 'YYYY-MM-DD']],
showResetButton: false,
},
beforeFetch: (params) => {
return { ...params, FormId: formIdComputedRef.value, PK: 'id',page:params.limit };
},
afterFetch: (res) => {
tableData.value = res || []
tableRef.value.setToolBarWidth();
},
useSearchForm: true,
showTableSetting: true,
striped: false,
actionColumn: {
width: 120,
title: '操作',
dataIndex: 'action',
slots: { customRender: 'action' },
},
rowSelection: {
type: 'checkbox',
onChange: onSelectChange
},
tableSetting: {
size: false,
setting: false,
},
});
watch(
() => tableData.value,
(val) => {
if (val) {
let arr = DataFormat.format(val, [
FormatOption.createQty('qtySalesGj'),
FormatOption.createQty('qtySalesM3'),
FormatOption.createQty('qtyMeaGj'),
FormatOption.createQty('qtyMeaM3'),
FormatOption.createQty('rateM3Gj', 6),
]);
if (arr.length) {
setTableData(arr)
}
}
},
{
immediate: true,
deep: true,
}
);
const handleDownload = (info) => {
const url = parseDownloadUrl(info.response ? info.response.data.fileUrl : info.fileUrl);
const fileName = info.response ? info.response.data.fileOrg : info.fileOrg;
downloadByUrl({ url, fileName: fileName});
};
function onSelectChange(selectedRowKeys: [], selectedRows) {
selectedKeys.value = selectedRowKeys;
}
function dbClickRow(record) {
}
function buttonClick(code) {
btnEvent[code]('batch');
}
async function handleSubmit (val) {
if (val=='batch') {
if (!selectedKeys.value.length) {
notification.warning({
message: '提示',
description: t('请选择需要确认的数据'),
});
return;
}
} else {
selectedKeys.value= [val?.id]
}
await submitLngPngMeasurePur(selectedKeys.value)
handleSuccess();
notification.success({
message: '提示',
description: t('确认成功!'),
});
clearSelectedRowKeys()
}
async function handleCancel (val) {
if (val=='batch') {
if (!selectedKeys.value.length) {
notification.warning({
message: '提示',
description: t('请选择需要取消的数据'),
});
return;
}
} else {
selectedKeys.value= [val?.id]
}
await cancelLngPngMeasurePur(selectedKeys.value)
handleSuccess();
notification.success({
message: '提示',
description: t('取消成功!'),
});
clearSelectedRowKeys()
}
function handleReject (val) {
if (val=='batch') {
if (!selectedKeys.value.length) {
notification.warning({
message: '提示',
description: t('请选择需要驳回的数据'),
});
return;
}
} else {
selectedKeys.value= [val?.id]
}
isOpen.value = true
}
const handleRejectReply = async (val) => {
let obj = {
"ids": selectedKeys.value,
"rejNote": val.reply,
}
await rejectLngPngMeasurePur(obj)
isOpen.value = false
handleSuccess();
notification.success({
message: '提示',
description: t('已驳回!'),
});
}
function handleDatalog (record: Recordable) {
modalVisible.value = true
logId.value = record.id
}
function handleRefresh() {
reload();
}
function handleSuccess() {
selectedKeys.value = [];
reload();
}
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 submitBtn: ActionItem[] = [];
let cancelBtn: ActionItem[] = [];
let rejectBtn: ActionItem[] = [];
let datalogBtn: ActionItem[] = [];
let actionsList: ActionItem[] = [];
actionButtonConfig.value?.map((button) => {
if (['submit'].includes(button.code)) {
submitBtn.push({
icon: button?.icon,
tooltip: button?.name,
onClick: btnEvent[button.code].bind(null, record),
});
}
if (['cancel'].includes(button.code)) {
cancelBtn.push({
icon: button?.icon,
tooltip: button?.name,
onClick: btnEvent[button.code].bind(null, record),
});
}
if (['reject'].includes(button.code)) {
rejectBtn.push({
icon: button?.icon,
tooltip: button?.name,
color: button.code === 'delete' ? 'error' : undefined,
onClick: btnEvent[button.code].bind(null, record),
});
}
if (['datalog'].includes(button.code)) {
datalogBtn.push({
icon: button?.icon,
tooltip: button?.name,
onClick: btnEvent[button.code].bind(null, record),
});
}
});
if (record.statusCode=='JLZ') {
actionsList = actionsList.concat(submitBtn);
}
if (record.statusCode=='JLWC') {
actionsList = actionsList.concat(cancelBtn);
}
if (record.statusCode=='JLZ'&&record.cfmCuUserId) {
actionsList = actionsList.concat(rejectBtn);
}
actionsList = actionsList.concat(datalogBtn);
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">
.PngMeasurePurStyle .cusSearchForm .advanceRow> div:nth-of-type(3){
display: none;
}
</style>
<style lang="less" scoped>
:deep(.ant-table-selection-col) {
width: 50px;
}
.show{
display: flex;
}
.hide{
display: none !important;
}
: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(2)) {
width: 330px !important;
max-width: 330px !important;
}
:deep(.ant-col-8:nth-child(2) .ant-form-item-label) {
width: 150px !important;
max-width: 150px !important;
}
:deep(.ant-col-8:nth-child(2) .ant-form-item-label label) {
width: 150px !important;
max-width: 150px !important;
}
:deep( .ant-col-8:nth-child(6)) {
width: 330px !important;
max-width: 330px !important;
}
:deep(.ant-col-8:nth-child(6) .ant-form-item-label) {
width: 150px !important;
max-width: 150px !important;
}
:deep(.ant-col-8:nth-child(6) .ant-form-item-label label) {
width: 150px !important;
max-width: 150px !important;
}
:deep( .ant-col-8:nth-child(3)) {
width: 330px !important;
max-width: 330px !important;
}
:deep(.ant-col-8:nth-child(3) .ant-form-item-label) {
width: 150px !important;
max-width: 150px !important;
}
:deep(.ant-col-8:nth-child(3) .ant-form-item-label label) {
width: 150px !important;
max-width: 150px !important;
}
:deep( .ant-col-8:nth-child(5)) {
width: 330px !important;
max-width: 330px !important;
}
:deep(.ant-col-8:nth-child(5) .ant-form-item-label) {
width: 150px !important;
max-width: 150px !important;
}
:deep(.ant-col-8:nth-child(5) .ant-form-item-label label) {
width: 150px !important;
max-width: 150px !important;
}
</style>

View File

@ -17,7 +17,7 @@ export const searchFormSchema: FormSchema[] = [
},
},
{
field: 'suCode',
field: 'suName',
label: '供应商名称/简称/编码',
component: 'Input',
},