回退物资批次需求计划
This commit is contained in:
@ -1,3 +1,792 @@
|
||||
<!-- <template>
|
||||
<div class="p-2">
|
||||
<el-row :gutter="20">
|
||||
<el-col style="" :span="5">
|
||||
<el-card shadow="hover">
|
||||
<template #header>
|
||||
<el-row :gutter="10" class="mb8">
|
||||
<el-col :span="1.5" :offset="0">
|
||||
<el-button type="primary" v-hasPermi="['cailiaoshebei:mrpBase:addbatch']" size="default" @click="handleAdd" icon="FolderAdd" plain
|
||||
>新增</el-button
|
||||
>
|
||||
</el-col>
|
||||
<el-col :span="1.5" :offset="0">
|
||||
<el-button
|
||||
type="danger"
|
||||
size="default"
|
||||
v-hasPermi="['cailiaoshebei:mrpBase:remove']"
|
||||
@click="handleDeleteBatch"
|
||||
:disabled="form.mrpBaseBo.status != 'draft'"
|
||||
icon="FolderDelete"
|
||||
plain
|
||||
>删除</el-button
|
||||
>
|
||||
</el-col>
|
||||
</el-row>
|
||||
</template>
|
||||
|
||||
<el-input v-model="batchNumber" placeholder="请输入批次号" @input="searchBatchList" prefix-icon="Search" clearable />
|
||||
<el-tree
|
||||
ref="batchTreeRef"
|
||||
class="mt-2"
|
||||
node-key="id"
|
||||
:data="batchOptions"
|
||||
:props="{ label: 'planCode', children: 'children' }"
|
||||
:expand-on-click-node="false"
|
||||
highlight-current
|
||||
default-expand-all
|
||||
@node-click="handleNodeClick"
|
||||
>
|
||||
<template #default="{ node, data }">
|
||||
<div class="custom-tree-node">
|
||||
{{ node.label }}
|
||||
<dict-tag :options="wf_business_status" :value="data.status" />
|
||||
</div>
|
||||
</template>
|
||||
</el-tree>
|
||||
<pagination
|
||||
v-show="total > 0"
|
||||
:total="total"
|
||||
v-model:page="queryParams.batchData.pageNum"
|
||||
v-model:limit="queryParams.batchData.pageSize"
|
||||
@pagination="getList"
|
||||
layout="prev, pager, next,jumper"
|
||||
/>
|
||||
</el-card>
|
||||
</el-col>
|
||||
<el-col :span="19">
|
||||
<el-card shadow="never">
|
||||
<template #header>
|
||||
<el-row :gutter="10" class="mb8">
|
||||
<el-col :span="1.5" v-if="form.mrpBaseBo.status == 'draft'">
|
||||
<el-button type="primary" plain icon="Edit" @click="handleUpdata" v-hasPermi="['cailiaoshebei:mrpBase:addbatch']">修改</el-button>
|
||||
</el-col>
|
||||
<el-col :span="1.5" v-if="form.mrpBaseBo.status == 'draft'">
|
||||
<el-button plain type="primary" icon="Finished" @click="handleAudit()">审核</el-button>
|
||||
</el-col>
|
||||
<el-col :span="1.5" v-if="form.mrpBaseBo.status != 'draft'">
|
||||
<el-button type="warning" icon="View" @click="handleAudit()">查看流程</el-button>
|
||||
</el-col>
|
||||
<right-toolbar v-model:showSearch="showSearch" @queryTable="getList"></right-toolbar>
|
||||
</el-row>
|
||||
</template>
|
||||
|
||||
<el-table v-loading="loading" :data="cailiaoshebeiList" @selection-change="handleSelectionChange">
|
||||
<el-table-column label="所属上级" align="center" prop="suppliespricePname" />
|
||||
<el-table-column label="物资名称" align="center" prop="name" />
|
||||
<el-table-column label="质量标准" align="center" prop="qs" />
|
||||
<el-table-column label="规格型号" align="center" prop="specification" />
|
||||
<el-table-column label="计量单位" align="center" prop="unit" width="80" />
|
||||
<el-table-column label="需求数量" align="center" prop="demandQuantity" />
|
||||
<el-table-column label="需求到货时间" align="center" prop="arrivalTime" width="250" />
|
||||
<el-table-column label="备注" align="center" prop="remark" />
|
||||
</el-table>
|
||||
<pagination
|
||||
v-show="mainTotal > 0"
|
||||
:total="mainTotal"
|
||||
v-model:page="queryParams.mainData.pageNum"
|
||||
v-model:limit="queryParams.mainData.pageSize"
|
||||
@pagination="getMainList"
|
||||
/>
|
||||
</el-card>
|
||||
</el-col>
|
||||
</el-row>
|
||||
<el-dialog :close-on-click-modal="false" draggable :title="dialog.title" v-model="dialog.visible" width="1500px" append-to-body>
|
||||
<el-form :model="form" ref="cailiaoshebeiFormRef" :rules="rules" label-width="80px" :inline="false">
|
||||
<el-divider>基础信息</el-divider>
|
||||
<el-row :gutter="20">
|
||||
<el-col :span="8" :offset="0">
|
||||
<el-form-item label="物资类别" prop="mrpBaseBo.matCat">
|
||||
<el-input v-model="form.mrpBaseBo.matCat" placeholder="请输入物资类别" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="8" :offset="0">
|
||||
<el-form-item label="编制日期" prop="mrpBaseBo.preparedDate">
|
||||
<el-date-picker v-model="form.mrpBaseBo.preparedDate" type="date" value-format="YYYY-MM-DD" placeholder="请选择编制日期" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="8" :offset="0">
|
||||
<el-form-item label="计划编号" prop="mrpBaseBo.planCode">
|
||||
<el-input v-model="form.mrpBaseBo.planCode" placeholder="请输入计划编号" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
|
||||
<el-divider>主要信息</el-divider>
|
||||
<el-table :data="form.planList" border>
|
||||
<el-table-column prop="batchNumber" align="center" label="版本号 " width="200">
|
||||
<template #default="scope">
|
||||
<el-select v-model="scope.row.batchNumber" placeholder="请选择" @change="(val) => selectNameVersion(val, scope.row, scope.$index)">
|
||||
<el-option v-for="item in versionList" :key="item.versions" :label="item.versions" :value="item.versions" />
|
||||
</el-select>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="name" align="center" label="物资名称" width="160">
|
||||
<template #default="scope">
|
||||
<el-input v-model="scope.row.name" v-if="scope.row.mrpBaseId" placeholder="请输入物资名称" disabled />
|
||||
<el-cascader
|
||||
v-else
|
||||
:disabled="!scope.row.batchNumber"
|
||||
v-model="scope.row.suppliespriceId"
|
||||
:show-all-levels="false"
|
||||
:options="getAvailableNameList(scope.$index)"
|
||||
placeholder="请选择"
|
||||
@change="(val) => selectName(val, scope.row, scope.$index)"
|
||||
:props="{
|
||||
label: 'name',
|
||||
value: 'id',
|
||||
children: 'children',
|
||||
emitPath: false
|
||||
}"
|
||||
/>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column align="center" label="剩余量" width="80">
|
||||
<template #default="scope">
|
||||
<span>{{ scope.row.Remaining }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="specification" align="center" label="规格型号" width="100">
|
||||
<template #default="scope">
|
||||
<span>{{ scope.row.specification }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="unit" align="center" label="单位" width="80">
|
||||
<template #default="scope">
|
||||
<span>{{ scope.row.unit }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="demandQuantity" align="center" label="数量" width="140">
|
||||
<template #default="scope">
|
||||
<el-input
|
||||
v-model.number="scope.row.demandQuantity"
|
||||
@input="validateDemandQuantity(scope.row, scope.$index)"
|
||||
@blur="validateDemandQuantity(scope.row, scope.$index)"
|
||||
:max="scope.row.Remaining"
|
||||
placeholder="请输入数量"
|
||||
type="number"
|
||||
min="0"
|
||||
/>
|
||||
<div v-if="scope.row.quantityError" class="text-red-500 text-xs mt-1">{{ scope.row.quantityError }}</div>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="qs" align="center" label="质量标准" width="140">
|
||||
<template #header> <span class="text-red-500">*</span> 质量标准 </template>
|
||||
<template #default="scope">
|
||||
<el-input v-model="scope.row.qs" placeholder="请输入质量标准" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="arrivalTime" align="center" label="需求到货时间" width="180">
|
||||
<template #header> <span class="text-red-500">*</span> 需求到货时间 </template>
|
||||
<template #default="scope">
|
||||
<el-date-picker v-model="scope.row.arrivalTime" type="date" value-format="YYYY-MM-DD" placeholder="请选择" style="width: 140px" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="remark" align="center" label="备注">
|
||||
<template #default="scope">
|
||||
<el-input v-model="scope.row.remark" placeholder="请输入备注" disabled />
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="remark" align="center" label="操作" width="150">
|
||||
<template #default="scope">
|
||||
<el-button @click="addRow" type="primary" icon="Plus" size="small" />
|
||||
<el-button @click="delRow(scope.$index)" type="danger" icon="Delete" size="small" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
</el-form>
|
||||
<template #footer>
|
||||
<div class="dialog-footer">
|
||||
<el-button :loading="buttonLoading" type="primary" @click="submitTransferForm">确 定</el-button>
|
||||
<el-button @click="cancel">取 消 </el-button>
|
||||
</div>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template> -->
|
||||
|
||||
<!-- <script setup name="Cailiaoshebei" lang="ts">
|
||||
// import {
|
||||
// getCailiaoshebei,
|
||||
// updateCailiaoshebei,
|
||||
// listBatch,
|
||||
// getBatch,
|
||||
// delBatch,
|
||||
// listSelectCailiaoshebei,
|
||||
// obtainTheVersion,
|
||||
// getDictList,
|
||||
// coryEngineeringList,
|
||||
// mrpBaseRemaining
|
||||
// } from '@/api/materials/batchPlan';
|
||||
// import { CailiaoshebeiVO, CailiaoshebeiQuery, CailiaoshebeiForm } from '@/api/materials/batchPlan/types';
|
||||
// import { useUserStoreHook } from '@/store/modules/user';
|
||||
// import { getCurrentInstance, ComponentInternalInstance, watch, onMounted, onUnmounted, computed } from 'vue';
|
||||
// import type { ElFormInstance } from 'element-plus';
|
||||
|
||||
// // 类型定义补充
|
||||
// interface DialogOption {
|
||||
// visible: boolean;
|
||||
// title: string;
|
||||
// }
|
||||
|
||||
// interface PlanListItem {
|
||||
// id?: number | undefined;
|
||||
// name?: string | undefined;
|
||||
// specification?: string | undefined;
|
||||
// unit?: string | undefined;
|
||||
// suppliespriceId?: number | undefined;
|
||||
// demandQuantity?: number | undefined;
|
||||
// qs?: string | undefined;
|
||||
// arrivalTime?: string | undefined;
|
||||
// remark?: string | undefined;
|
||||
// Remaining: number; // 剩余量(必存在)
|
||||
// quantityError: string; // 数量错误提示
|
||||
// batchNumber?: string | undefined; // 版本号
|
||||
// duplicateError: string; // 重复错误提示
|
||||
// mrpBaseId?: number | undefined;
|
||||
// }
|
||||
|
||||
// interface FormData {
|
||||
// mrpBaseBo: {
|
||||
// id?: number | undefined;
|
||||
// preparedDate?: string | undefined;
|
||||
// planCode?: string | undefined;
|
||||
// matCat?: string | undefined;
|
||||
// status?: string | undefined;
|
||||
// projectId?: number | undefined;
|
||||
// };
|
||||
// planList: PlanListItem[];
|
||||
// }
|
||||
|
||||
// const { proxy } = getCurrentInstance() as ComponentInternalInstance;
|
||||
// // 获取用户 store
|
||||
// const userStore = useUserStoreHook();
|
||||
// // 从 store 中获取项目列表和当前选中的项目
|
||||
// const currentProject = computed(() => userStore.selectedProject);
|
||||
// const batchTreeRef = ref<any>(null);
|
||||
// const cailiaoshebeiList = ref<CailiaoshebeiVO[]>([]);
|
||||
// const buttonLoading = ref(false);
|
||||
// const loading = ref(false);
|
||||
// const showSearch = ref(true);
|
||||
// const ids = ref<Array<string | number>>([]);
|
||||
// const single = ref(true);
|
||||
// const multiple = ref(true);
|
||||
// const total = ref(0);
|
||||
// const mainTotal = ref(0);
|
||||
// const batchOptions = ref<any[]>([]);
|
||||
// const { wf_business_status } = toRefs<any>(proxy?.useDict('wf_business_status') || {});
|
||||
// const route = useRoute();
|
||||
// const queryFormRef = ref<ElFormInstance>();
|
||||
// const cailiaoshebeiFormRef = ref<ElFormInstance>();
|
||||
// const dialog = reactive<DialogOption>({
|
||||
// visible: false,
|
||||
// title: ''
|
||||
// });
|
||||
|
||||
// // 初始化表单数据
|
||||
// const initFormData: FormData = {
|
||||
// mrpBaseBo: {
|
||||
// id: undefined,
|
||||
// preparedDate: undefined,
|
||||
// planCode: undefined,
|
||||
// matCat: undefined,
|
||||
// status: undefined,
|
||||
// projectId: currentProject.value?.id
|
||||
// },
|
||||
// planList: [
|
||||
// {
|
||||
// id: undefined,
|
||||
// name: undefined,
|
||||
// specification: undefined,
|
||||
// unit: undefined,
|
||||
// suppliespriceId: undefined,
|
||||
// demandQuantity: undefined,
|
||||
// qs: undefined,
|
||||
// arrivalTime: undefined,
|
||||
// remark: undefined,
|
||||
// Remaining: 0,
|
||||
// quantityError: '',
|
||||
// batchNumber: undefined,
|
||||
// duplicateError: '',
|
||||
// mrpBaseId: undefined
|
||||
// }
|
||||
// ]
|
||||
// };
|
||||
|
||||
// const data = reactive({
|
||||
// form: { ...initFormData } as FormData,
|
||||
// queryParams: {
|
||||
// batchData: {
|
||||
// pageNum: 1,
|
||||
// pageSize: 10,
|
||||
// planCode: undefined,
|
||||
// projectId: currentProject.value?.id
|
||||
// },
|
||||
// mainData: {
|
||||
// pageNum: 1,
|
||||
// pageSize: 10,
|
||||
// mrpBaseId: undefined,
|
||||
// projectId: currentProject.value?.id
|
||||
// }
|
||||
// },
|
||||
// rules: {
|
||||
// id: [{ required: true, message: '主键ID不能为空', trigger: 'blur' }],
|
||||
// 'mrpBaseBo.preparedDate': [{ required: true, message: '计划日期不能为空', trigger: 'blur' }],
|
||||
// 'mrpBaseBo.planCode': [{ required: true, message: '计划编码不能为空', trigger: 'blur' }],
|
||||
// 'mrpBaseBo.matCat': [{ required: true, message: '物资分类不能为空', trigger: 'blur' }]
|
||||
// }
|
||||
// });
|
||||
|
||||
// const batchNumber = ref('');
|
||||
// const { queryParams, form, rules } = toRefs(data);
|
||||
// const nameList = ref<any[]>([]);
|
||||
// const versionList = ref<any[]>([]);
|
||||
|
||||
// /** 查询物资-材料设备列表 */
|
||||
// const getList = async (type?: string) => {
|
||||
// loading.value = true;
|
||||
// try {
|
||||
// const res = await listBatch(queryParams.value.batchData);
|
||||
// batchOptions.value = res.rows || [];
|
||||
// // 自动选中第一条数据(如果存在且未选中)
|
||||
// if (batchOptions.value.length > 0 && !queryParams.value.mainData.mrpBaseId) {
|
||||
// batchTreeRef.value?.setCurrentKey(batchOptions.value[0].id);
|
||||
// queryParams.value.mainData.mrpBaseId = batchOptions.value[0].id;
|
||||
// form.value.mrpBaseBo.status = batchOptions.value[0].status;
|
||||
// }
|
||||
// total.value = res.total || 0;
|
||||
// } catch (error) {
|
||||
// proxy?.$modal.msgError('获取批次列表失败');
|
||||
// } finally {
|
||||
// loading.value = false;
|
||||
// // 非搜索场景下同步加载主列表
|
||||
// if (type !== 'search') {
|
||||
// getMainList();
|
||||
// }
|
||||
// }
|
||||
// };
|
||||
|
||||
// /** 数量校验:必须≤剩余量,且为合法数字 */
|
||||
// const validateDemandQuantity = (row: PlanListItem, index: number) => {
|
||||
// // 1. 清除之前的错误信息
|
||||
// row.quantityError = '';
|
||||
|
||||
// // 2. 处理空值
|
||||
// if (row.demandQuantity === null || row.demandQuantity === undefined || row.demandQuantity === '') {
|
||||
// return;
|
||||
// }
|
||||
|
||||
// // 3. 处理非数字
|
||||
// if (typeof row.demandQuantity !== 'number' || isNaN(row.demandQuantity)) {
|
||||
// row.quantityError = '请输入合法数字';
|
||||
// return;
|
||||
// }
|
||||
|
||||
// // 4. 处理负数
|
||||
// if (row.demandQuantity < 0) {
|
||||
// row.quantityError = '数量不能为负数';
|
||||
// return;
|
||||
// }
|
||||
|
||||
// // 5. 核心校验:数量≤剩余量
|
||||
// if (row.demandQuantity > row.Remaining) {
|
||||
// row.quantityError = `数量不能超过剩余量${row.Remaining}`;
|
||||
// }
|
||||
// };
|
||||
|
||||
// /** 获取剩余量 */
|
||||
// const getMrpBaseRemaining = async (suppliespriceId: number, row: PlanListItem) => {
|
||||
// try {
|
||||
// const res = await mrpBaseRemaining({ suppliespriceId });
|
||||
// const selected = res.data;
|
||||
// console.log('🚀 ~ getMrpBaseRemaining ~ selected:', selected);
|
||||
// row.Remaining = selected.remainingQuantity || 0;
|
||||
// row.name = selected.name;
|
||||
// row.specification = selected.specification;
|
||||
// row.unit = selected.unit;
|
||||
// row.qs = selected.qs || '';
|
||||
// row.remark = selected.remark || '';
|
||||
// row.arrivalTime = selected.arrivalTime || '';
|
||||
// // 剩余量更新后,重新校验当前数量
|
||||
// validateDemandQuantity(row, 0);
|
||||
// } catch (error) {
|
||||
// proxy?.$modal.msgError('获取剩余量失败');
|
||||
// row.Remaining = 0;
|
||||
// }
|
||||
// };
|
||||
|
||||
// /** 获取可用物资列表(过滤已选选项) */
|
||||
// const getAvailableNameList = (currentIndex: number) => {
|
||||
// // 收集除当前行外已选中的物资ID
|
||||
// const selectedIds = form.value.planList
|
||||
// .filter((_, index) => index !== currentIndex)
|
||||
// .map((item) => item.suppliespriceId)
|
||||
// .filter((id) => id !== undefined && id !== null);
|
||||
|
||||
// // 过滤掉已选中的物资
|
||||
// return nameList.value.filter((item) => !selectedIds.includes(item.id));
|
||||
// };
|
||||
|
||||
// /** 选择物资名称触发 */
|
||||
// const selectName = (val: number, row: PlanListItem, index: number) => {
|
||||
// // 1. 获取剩余量并更新基础信息
|
||||
// getMrpBaseRemaining(val, row);
|
||||
// };
|
||||
|
||||
// /** 节点单击事件 */
|
||||
// const handleNodeClick = (data: any) => {
|
||||
// queryParams.value.mainData.mrpBaseId = data.id;
|
||||
// form.value.mrpBaseBo.status = data.status;
|
||||
// getMainList();
|
||||
// };
|
||||
|
||||
// /** 获取主列表数据 */
|
||||
// const getMainList = async () => {
|
||||
// if (!queryParams.value.mainData.mrpBaseId) return;
|
||||
|
||||
// loading.value = true;
|
||||
// try {
|
||||
// const res = await getBatch(queryParams.value.mainData);
|
||||
// cailiaoshebeiList.value = res.rows || [];
|
||||
// mainTotal.value = res.total || 0;
|
||||
// } catch (error) {
|
||||
// proxy?.$modal.msgError('获取物资列表失败');
|
||||
// } finally {
|
||||
// loading.value = false;
|
||||
// }
|
||||
// };
|
||||
|
||||
// /** 搜索批次列表 */
|
||||
// const searchBatchList = async () => {
|
||||
// queryParams.value.batchData.planCode = batchNumber.value;
|
||||
// getList('search');
|
||||
// };
|
||||
|
||||
// /** 删除表格行 */
|
||||
// const delRow = (index: number) => {
|
||||
// if (form.value.planList.length <= 1) {
|
||||
// return proxy?.$modal.msgWarning('请至少保留一项物资数据');
|
||||
// }
|
||||
// form.value.planList.splice(index, 1);
|
||||
// };
|
||||
|
||||
// /** 新增表格行 */
|
||||
// const addRow = () => {
|
||||
// const newRow: PlanListItem = {
|
||||
// name: undefined,
|
||||
// specification: undefined,
|
||||
// unit: undefined,
|
||||
// suppliespriceId: undefined,
|
||||
// demandQuantity: undefined,
|
||||
// qs: undefined,
|
||||
// arrivalTime: undefined,
|
||||
// remark: undefined,
|
||||
// Remaining: 0,
|
||||
// quantityError: '',
|
||||
// batchNumber: undefined,
|
||||
// duplicateError: '',
|
||||
// mrpBaseId: undefined
|
||||
// };
|
||||
// form.value.planList.push(newRow);
|
||||
// };
|
||||
|
||||
// /** 取消按钮 */
|
||||
// const cancel = () => {
|
||||
// reset();
|
||||
// dialog.visible = false;
|
||||
// };
|
||||
|
||||
// /** 表单重置 */
|
||||
// const reset = () => {
|
||||
// const status = form.value.mrpBaseBo.status;
|
||||
// // 重置表单(保留状态字段)
|
||||
// form.value = {
|
||||
// ...JSON.parse(JSON.stringify(initFormData)),
|
||||
// mrpBaseBo: { ...initFormData.mrpBaseBo, status }
|
||||
// };
|
||||
// // 重置表单验证状态
|
||||
// cailiaoshebeiFormRef.value?.resetFields();
|
||||
// // 重置项目ID
|
||||
// form.value.mrpBaseBo.projectId = currentProject.value?.id;
|
||||
// };
|
||||
|
||||
// /** 多选框选中数据 */
|
||||
// const handleSelectionChange = (selection: CailiaoshebeiVO[]) => {
|
||||
// ids.value = selection.map((item) => item.id);
|
||||
// single.value = selection.length !== 1;
|
||||
// multiple.value = selection.length === 0;
|
||||
// };
|
||||
|
||||
// /** 新增按钮操作 */
|
||||
// const handleAdd = () => {
|
||||
// reset();
|
||||
// dialog.visible = true;
|
||||
// dialog.title = '新增物资-需求';
|
||||
// };
|
||||
|
||||
// /** 修改按钮操作 */
|
||||
// const handleUpdata = () => {
|
||||
// if (!queryParams.value.mainData.mrpBaseId) {
|
||||
// return proxy?.$modal.msgError('请先选择批次');
|
||||
// }
|
||||
// // 获取对应版本的物资列表
|
||||
// reset();
|
||||
// loading.value = true;
|
||||
// getCailiaoshebei(queryParams.value.mainData.mrpBaseId)
|
||||
// .then((res: any) => {
|
||||
// // 更新基础信息
|
||||
// form.value.mrpBaseBo = res.data.mrpBaseBo || initFormData.mrpBaseBo;
|
||||
|
||||
// // 更新表格数据(补充缺失字段)
|
||||
// form.value.planList = (res.data.planList || []).map((item: any) => ({
|
||||
// id: item.id,
|
||||
// name: item.name,
|
||||
// specification: item.specification,
|
||||
// unit: item.unit,
|
||||
// suppliespriceId: item.suppliespriceId,
|
||||
// demandQuantity: item.demandQuantity,
|
||||
// qs: item.qs,
|
||||
// arrivalTime: item.arrivalTime,
|
||||
// remark: item.remark,
|
||||
// Remaining: Number(item.remaining) || 0,
|
||||
// quantityError: '',
|
||||
// batchNumber: item.batchNumber,
|
||||
// duplicateError: '',
|
||||
// mrpBaseId: item.mrpBaseId
|
||||
// }));
|
||||
// // 打开对话框
|
||||
// dialog.visible = true;
|
||||
// dialog.title = '修改物资-需求';
|
||||
// })
|
||||
// .catch(() => {
|
||||
// proxy?.$modal.msgError('获取详情失败');
|
||||
// })
|
||||
// .finally(() => {
|
||||
// loading.value = false;
|
||||
// });
|
||||
// };
|
||||
|
||||
// /** 提交数据(整合所有校验) */
|
||||
// const submitTransferForm = async () => {
|
||||
// // 1. 校验数量合法性(检查是否有数量错误)
|
||||
// const hasQuantityError = form.value.planList.some((row) => row.quantityError);
|
||||
// if (hasQuantityError) {
|
||||
// return proxy?.$modal.msgError('存在非法数量,请修正后提交');
|
||||
// }
|
||||
|
||||
// // 2. 执行表单基础验证
|
||||
// const result = validateAndClean(form.value.planList);
|
||||
// if (!result.valid) {
|
||||
// return proxy?.$modal.msgError(result.message);
|
||||
// }
|
||||
|
||||
// // 3. 表单组件验证
|
||||
// cailiaoshebeiFormRef.value?.validate(async (valid: boolean) => {
|
||||
// if (!valid) return;
|
||||
|
||||
// buttonLoading.value = true;
|
||||
// try {
|
||||
// // 4. 提交数据
|
||||
// await updateCailiaoshebei({
|
||||
// ...form.value,
|
||||
// planList: result.data // 使用清洗后的数据
|
||||
// });
|
||||
// proxy?.$modal.msgSuccess('操作成功');
|
||||
// dialog.visible = false;
|
||||
// // 5. 刷新列表
|
||||
// await getList();
|
||||
// } catch (error) {
|
||||
// proxy?.$modal.msgError('操作失败,请重试');
|
||||
// } finally {
|
||||
// buttonLoading.value = false;
|
||||
// }
|
||||
// });
|
||||
// };
|
||||
|
||||
// /** 删除批次 */
|
||||
// const handleDeleteBatch = async () => {
|
||||
// const _id = batchTreeRef.value?.getCurrentNode()?.id;
|
||||
// if (!_id) {
|
||||
// return proxy?.$modal.msgError('请先选择批次');
|
||||
// }
|
||||
|
||||
// try {
|
||||
// await proxy?.$modal.confirm('是否确认删除该批次?删除后不可恢复!');
|
||||
// await delBatch(_id);
|
||||
// proxy?.$modal.msgSuccess('删除成功');
|
||||
// // 重置选中状态并刷新列表
|
||||
// queryParams.value.mainData.mrpBaseId = undefined;
|
||||
// form.value.mrpBaseBo.status = undefined;
|
||||
// await getList();
|
||||
// } catch (error) {
|
||||
// // 取消确认时不提示错误
|
||||
// if (error !== 'cancel') {
|
||||
// proxy?.$modal.msgError('删除失败');
|
||||
// }
|
||||
// }
|
||||
// };
|
||||
|
||||
// /** 数据清洗与基础校验 */
|
||||
// function validateAndClean(arr: PlanListItem[]) {
|
||||
// // 1. 过滤掉全空的数据项
|
||||
// const cleanedArr = arr.filter((item) => !Object.values(item).every((v) => v === '' || v == null || v === undefined));
|
||||
|
||||
// let hasFullItem = false; // 是否有至少一条完整数据
|
||||
|
||||
// // 2. 逐行校验必填项
|
||||
// for (let idx = 0; idx < cleanedArr.length; idx++) {
|
||||
// const item = cleanedArr[idx];
|
||||
|
||||
// // 校验版本号
|
||||
// if (!item.batchNumber) {
|
||||
// return { valid: false, message: `第${idx + 1}行:版本号不能为空`, data: cleanedArr };
|
||||
// }
|
||||
|
||||
// // 校验物资选择
|
||||
// if (!item.suppliespriceId) {
|
||||
// return { valid: false, message: `第${idx + 1}行:请选择物资名称`, data: cleanedArr };
|
||||
// }
|
||||
|
||||
// // 校验质量标准
|
||||
// if (!item.qs) {
|
||||
// return { valid: false, message: `第${idx + 1}行:质量标准不能为空`, data: cleanedArr };
|
||||
// }
|
||||
|
||||
// // 校验需求到货时间
|
||||
// if (!item.arrivalTime) {
|
||||
// return { valid: false, message: `第${idx + 1}行:需求到货时间不能为空`, data: cleanedArr };
|
||||
// }
|
||||
|
||||
// // 校验数量(必填且≥0)
|
||||
// if (item.demandQuantity === null || item.demandQuantity === undefined || item.demandQuantity < 0) {
|
||||
// return { valid: false, message: `第${idx + 1}行:请输入合法的需求数量`, data: cleanedArr };
|
||||
// }
|
||||
|
||||
// hasFullItem = true;
|
||||
// }
|
||||
|
||||
// // 3. 检查是否至少有一条完整数据
|
||||
// if (!hasFullItem) {
|
||||
// return { valid: false, message: '至少需要填写一条完整的物资数据', data: cleanedArr };
|
||||
// }
|
||||
|
||||
// return { valid: true, message: '', data: cleanedArr };
|
||||
// }
|
||||
|
||||
// /** 审核按钮操作 */
|
||||
// const handleAudit = async () => {
|
||||
// if (!form.value.mrpBaseBo.status) {
|
||||
// return proxy?.$modal.msgError('请选择批次号');
|
||||
// }
|
||||
// if (!queryParams.value.mainData.mrpBaseId) {
|
||||
// return proxy?.$modal.msgError('请选择批次号');
|
||||
// }
|
||||
|
||||
// // 关闭当前页并打开审核页
|
||||
// proxy?.$tab.closePage(route);
|
||||
// proxy?.$tab.openPage('/approval/batchPlan/indexEdit', '审核物资设备批次需求计划', {
|
||||
// id: queryParams.value.mainData.mrpBaseId,
|
||||
// status: `${form.value.mrpBaseBo.status}_batchRequirements`,
|
||||
// type: 'update'
|
||||
// });
|
||||
// };
|
||||
|
||||
// /** 获取物资列表(按版本号筛选) */
|
||||
// const getNameList = (versions: string) => {
|
||||
// coryEngineeringList({
|
||||
// projectId: currentProject.value?.id,
|
||||
// versions
|
||||
// })
|
||||
// .then((res: any) => {
|
||||
// nameList.value = res.data || [];
|
||||
// })
|
||||
// .catch(() => {
|
||||
// nameList.value = [];
|
||||
// proxy?.$modal.msgError('获取物资列表失败');
|
||||
// });
|
||||
// };
|
||||
|
||||
// /** 获取版本号列表 */
|
||||
// const getVersion = () => {
|
||||
// obtainTheVersion({ projectId: currentProject.value?.id })
|
||||
// .then((res: any) => {
|
||||
// versionList.value = res.data || [];
|
||||
// })
|
||||
// .catch(() => {
|
||||
// versionList.value = [];
|
||||
// proxy?.$modal.msgError('获取版本号失败');
|
||||
// });
|
||||
// };
|
||||
|
||||
// /** 选择版本号触发 */
|
||||
// const selectNameVersion = (val: string, row: PlanListItem, index: number) => {
|
||||
// row.batchNumber = val;
|
||||
// row.suppliespriceId = undefined; // 切换版本号时清空物资选择
|
||||
// row.name = undefined;
|
||||
// row.specification = undefined;
|
||||
// row.unit = undefined;
|
||||
// row.qs = undefined;
|
||||
// row.remark = undefined;
|
||||
// row.arrivalTime = undefined;
|
||||
// row.demandQuantity = undefined;
|
||||
// row.quantityError = '';
|
||||
// row.duplicateError = '';
|
||||
// row.mrpBaseId = '';
|
||||
|
||||
// // 获取对应版本的物资列表
|
||||
// getNameList(val);
|
||||
// };
|
||||
|
||||
// /** 页面挂载时初始化 */
|
||||
// onMounted(() => {
|
||||
// getList();
|
||||
// getVersion();
|
||||
// });
|
||||
|
||||
// /** 监听项目ID变化,刷新数据 */
|
||||
// const listeningProject = watch(
|
||||
// () => currentProject.value?.id,
|
||||
// (newId, oldId) => {
|
||||
// if (newId !== oldId && newId) {
|
||||
// queryParams.value.mainData.projectId = newId;
|
||||
// queryParams.value.batchData.projectId = newId;
|
||||
// form.value.mrpBaseBo.projectId = newId;
|
||||
// getList();
|
||||
// getVersion(); // 重新获取对应项目的版本号
|
||||
// }
|
||||
// }
|
||||
// );
|
||||
|
||||
// /** 页面卸载时清理监听 */
|
||||
// onUnmounted(() => {
|
||||
// listeningProject();
|
||||
// });
|
||||
// </script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.custom-tree-node {
|
||||
flex: 1;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
font-size: 14px;
|
||||
padding-right: 8px;
|
||||
}
|
||||
|
||||
/* 错误提示样式补充 */
|
||||
.text-red-500 {
|
||||
color: #f56c6c;
|
||||
}
|
||||
|
||||
.text-xs {
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.dialog-footer {
|
||||
text-align: right;
|
||||
}
|
||||
</style> -->
|
||||
|
||||
<template>
|
||||
<div class="p-2">
|
||||
<el-row :gutter="20">
|
||||
|
||||
@ -430,7 +430,14 @@
|
||||
<el-timeline-item color="rgb(255, 73, 73)">
|
||||
<div class="mb">{{ '退场时间:' + item.entryDate }}</div>
|
||||
<div class="pl-xl">
|
||||
<span class="text-coolgray font-bold">退场文件:<image-preview v-for="itm in item.pathUrl" :src="itm" width="100px" class="mr" /></span
|
||||
<span class="text-coolgray font-bold"
|
||||
>退场文件:<el-link
|
||||
v-for="itm in [...item.salaryConfirmationFileUrl, ...item.salaryVoucherFileUrl]"
|
||||
:href="itm"
|
||||
target="_blank"
|
||||
type="primary"
|
||||
>{{ itm }}</el-link
|
||||
></span
|
||||
><br />
|
||||
<p class="mt text-coolgray">
|
||||
备注:<span class="text-blue">{{ item.remark }}</span>
|
||||
@ -1060,7 +1067,7 @@ const submitForm = () => {
|
||||
const handleJoinBlacklist = async (row?: ConstructionUserVO) => {
|
||||
await proxy?.$modal.confirm('确认要将该员工加入黑名单吗?').finally(() => (loading.value = false));
|
||||
await addConstructionBlacklist({
|
||||
userId: row.id,
|
||||
userId: row.sysUserId,
|
||||
projectId: currentProject.value?.id
|
||||
});
|
||||
proxy?.$modal.msgSuccess('加入成功');
|
||||
|
||||
Reference in New Issue
Block a user