物料需求计划 编辑页数据加载

物料需求计划 编辑页数据加载
pull/4/head
siontion 8 months ago
parent 345ab3f022
commit d5548fddde

@ -1,6 +1,8 @@
package com.chanko.yunxi.mes.module.heli.controller.admin.materialplandetail.vo; package com.chanko.yunxi.mes.module.heli.controller.admin.materialplandetail.vo;
import lombok.*; import lombok.*;
import java.math.BigDecimal;
import java.util.*; import java.util.*;
import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.media.Schema;
import com.chanko.yunxi.mes.framework.common.pojo.PageParam; import com.chanko.yunxi.mes.framework.common.pojo.PageParam;
@ -28,7 +30,7 @@ public class MaterialPlanDetailPageReqVO extends PageParam {
private Long projectSubId; private Long projectSubId;
@Schema(description = "需求数量") @Schema(description = "需求数量")
private Long requireAmount; private BigDecimal requireAmount;
@Schema(description = "需求到货日期") @Schema(description = "需求到货日期")
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)

@ -2,6 +2,8 @@ package com.chanko.yunxi.mes.module.heli.controller.admin.materialplandetail.vo;
import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*; import lombok.*;
import java.math.BigDecimal;
import java.util.*; import java.util.*;
import java.util.*; import java.util.*;
import org.springframework.format.annotation.DateTimeFormat; import org.springframework.format.annotation.DateTimeFormat;
@ -31,7 +33,7 @@ public class MaterialPlanDetailRespVO {
@Schema(description = "需求数量") @Schema(description = "需求数量")
@ExcelProperty("需求数量") @ExcelProperty("需求数量")
private Long requireAmount; private BigDecimal requireAmount;
@Schema(description = "需求到货日期") @Schema(description = "需求到货日期")
@ExcelProperty("需求到货日期") @ExcelProperty("需求到货日期")
@ -45,4 +47,28 @@ public class MaterialPlanDetailRespVO {
@ExcelProperty("创建时间") @ExcelProperty("创建时间")
private LocalDateTime createTime; private LocalDateTime createTime;
@Schema(description = "物料id", requiredMode = Schema.RequiredMode.REQUIRED)
@ExcelProperty("物料id")
private Long matId;
@Schema(description = "备注")
@ExcelProperty("物料名称")
private String matName;
@Schema(description = "备注")
@ExcelProperty("物料编码")
private String matCode;
@Schema(description = "备注")
@ExcelProperty("物料规格型号")
private String matSpec;
@Schema(description = "备注")
@ExcelProperty("物料单位")
private String matUnit;
@Schema(description = "备注")
@ExcelProperty("物料类型")
private String matType;
} }

@ -2,6 +2,8 @@ package com.chanko.yunxi.mes.module.heli.controller.admin.materialplandetail.vo;
import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*; import lombok.*;
import java.math.BigDecimal;
import java.util.*; import java.util.*;
import javax.validation.constraints.*; import javax.validation.constraints.*;
import java.util.*; import java.util.*;
@ -27,7 +29,7 @@ public class MaterialPlanDetailSaveReqVO {
private Long projectSubId; private Long projectSubId;
@Schema(description = "需求数量") @Schema(description = "需求数量")
private Long requireAmount; private BigDecimal requireAmount;
@Schema(description = "需求到货日期") @Schema(description = "需求到货日期")
private LocalDateTime requireArriveTime; private LocalDateTime requireArriveTime;

@ -1,6 +1,8 @@
package com.chanko.yunxi.mes.module.heli.dal.dataobject.materialplandetail; package com.chanko.yunxi.mes.module.heli.dal.dataobject.materialplandetail;
import lombok.*; import lombok.*;
import java.math.BigDecimal;
import java.util.*; import java.util.*;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.time.LocalDateTime; import java.time.LocalDateTime;
@ -43,7 +45,7 @@ public class MaterialPlanDetailDO extends BaseDO {
/** /**
* *
*/ */
private Long requireAmount; private BigDecimal requireAmount;
/** /**
* *
*/ */
@ -53,4 +55,17 @@ public class MaterialPlanDetailDO extends BaseDO {
*/ */
private String description; private String description;
@TableField(exist = false)
private Long matId;
@TableField(exist = false)
private String matName;
@TableField(exist = false)
private String matCode;
@TableField(exist = false)
private String matSpec;
@TableField(exist = false)
private String matUnit;
@TableField(exist = false)
private String matType;
} }

@ -5,9 +5,16 @@ import java.util.*;
import com.chanko.yunxi.mes.framework.common.pojo.PageResult; import com.chanko.yunxi.mes.framework.common.pojo.PageResult;
import com.chanko.yunxi.mes.framework.mybatis.core.query.LambdaQueryWrapperX; import com.chanko.yunxi.mes.framework.mybatis.core.query.LambdaQueryWrapperX;
import com.chanko.yunxi.mes.framework.mybatis.core.mapper.BaseMapperX; import com.chanko.yunxi.mes.framework.mybatis.core.mapper.BaseMapperX;
import com.chanko.yunxi.mes.module.heli.controller.admin.materialplan.vo.MaterialPlanPageReqVO;
import com.chanko.yunxi.mes.module.heli.dal.dataobject.material.MaterialDO;
import com.chanko.yunxi.mes.module.heli.dal.dataobject.materialplan.MaterialPlanDO;
import com.chanko.yunxi.mes.module.heli.dal.dataobject.materialplandetail.MaterialPlanDetailDO; import com.chanko.yunxi.mes.module.heli.dal.dataobject.materialplandetail.MaterialPlanDetailDO;
import com.chanko.yunxi.mes.module.heli.dal.dataobject.plan.PlanDO;
import com.chanko.yunxi.mes.module.heli.dal.dataobject.projectorder.ProjectOrderDO;
import com.github.yulichang.wrapper.MPJLambdaWrapper;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import com.chanko.yunxi.mes.module.heli.controller.admin.materialplandetail.vo.*; import com.chanko.yunxi.mes.module.heli.controller.admin.materialplandetail.vo.*;
import org.springframework.util.StringUtils;
/** /**
* Mapper * Mapper
@ -18,16 +25,28 @@ import com.chanko.yunxi.mes.module.heli.controller.admin.materialplandetail.vo.*
public interface MaterialPlanDetailMapper extends BaseMapperX<MaterialPlanDetailDO> { public interface MaterialPlanDetailMapper extends BaseMapperX<MaterialPlanDetailDO> {
default PageResult<MaterialPlanDetailDO> selectPage(MaterialPlanDetailPageReqVO reqVO) { default PageResult<MaterialPlanDetailDO> selectPage(MaterialPlanDetailPageReqVO reqVO) {
return selectPage(reqVO, new LambdaQueryWrapperX<MaterialPlanDetailDO>() MPJLambdaWrapper<MaterialPlanDetailDO> query = new MPJLambdaWrapper<>();
.eqIfPresent(MaterialPlanDetailDO::getId, reqVO.getId())
.eqIfPresent(MaterialPlanDetailDO::getProjectMaterialPlanId, reqVO.getProjectMaterialPlanId()) query.selectAll(MaterialPlanDetailDO.class)
.eqIfPresent(MaterialPlanDetailDO::getMaterialId, reqVO.getMaterialId()) .select("mat.id as matId","mat.name as matName","mat.code as matCode","mat.spec as matSpec","mat.unit as matUnit","mat.material_type as matType")
.eqIfPresent(MaterialPlanDetailDO::getProjectSubId, reqVO.getProjectSubId()) .leftJoin(MaterialDO.class, "mat", MaterialDO::getId, MaterialPlanDetailDO::getMaterialId)
.eqIfPresent(MaterialPlanDetailDO::getRequireAmount, reqVO.getRequireAmount()) .disableSubLogicDel()
.betweenIfPresent(MaterialPlanDetailDO::getRequireArriveTime, reqVO.getRequireArriveTime()) .orderByDesc(MaterialPlanDetailDO::getCreateTime);
.eqIfPresent(MaterialPlanDetailDO::getDescription, reqVO.getDescription()) query.eq(reqVO.getProjectMaterialPlanId()!=null,MaterialPlanDetailDO::getProjectMaterialPlanId, reqVO.getProjectMaterialPlanId()).orderByAsc(MaterialPlanDetailDO::getCreateTime);
.betweenIfPresent(MaterialPlanDetailDO::getCreateTime, reqVO.getCreateTime())
.orderByDesc(MaterialPlanDetailDO::getId)); return selectPage(reqVO, query);
} }
// default PageResult<MaterialPlanDetailDO> selectPage(MaterialPlanDetailPageReqVO reqVO) {
// return selectPage(reqVO, new LambdaQueryWrapperX<MaterialPlanDetailDO>()
// .eqIfPresent(MaterialPlanDetailDO::getId, reqVO.getId())
// .eqIfPresent(MaterialPlanDetailDO::getProjectMaterialPlanId, reqVO.getProjectMaterialPlanId())
// .eqIfPresent(MaterialPlanDetailDO::getMaterialId, reqVO.getMaterialId())
// .eqIfPresent(MaterialPlanDetailDO::getProjectSubId, reqVO.getProjectSubId())
// .eqIfPresent(MaterialPlanDetailDO::getRequireAmount, reqVO.getRequireAmount())
// .betweenIfPresent(MaterialPlanDetailDO::getRequireArriveTime, reqVO.getRequireArriveTime())
// .eqIfPresent(MaterialPlanDetailDO::getDescription, reqVO.getDescription())
// .betweenIfPresent(MaterialPlanDetailDO::getCreateTime, reqVO.getCreateTime())
// .orderByDesc(MaterialPlanDetailDO::getId));
// }
} }

@ -0,0 +1,566 @@
<template>
<el-card class="hl-card" style="position: relative">
<template #header>
<span>编辑页</span>
</template>
<el-form ref="formRef" :model="formData" :rules="formRules" label-width="160px" v-loading="formLoading">
<!-- 基础信息 -->
<el-card class="hl-card-info">
<template #header>
<div class="hl-card-info-icona"></div><span class="hl-card-info-text">基础信息</span>
</template>
<el-row>
<el-col :span="24">
<el-row>
<el-col :span="6">
<el-row>
<el-col :span="24">
<el-form-item label="物料需求计划编号" prop="projectMaterialPlanNo">
<el-input class="!w-265px" placeholder="系统自动生成" v-model="formData.projectMaterialPlanNo" disabled />
</el-form-item>
</el-col>
</el-row>
<el-row>
<el-col :span="80">
<el-form-item label="备注" prop="description">
<el-input class="!w-713px" type="textarea" v-model="formData.description" show-word-limit
maxlength="200" />
</el-form-item>
</el-col>
</el-row>
</el-col>
<el-col :span="6">
<el-row>
<el-col :span="24">
<el-form-item label="单据日期" prop="createTime">
<el-date-picker class="!w-265px" v-model="formData.createTime" value-format="x" placeholder="单据日期"
disabled />
</el-form-item>
</el-col>
</el-row>
</el-col>
<el-col :span="6">
<el-row>
<el-col :span="24">
<el-form-item label="生产计划单号" prop="planNo">
<el-input class="!w-265px" placeholder="生产计划单号" v-model="formData.planNo" disabled />
</el-form-item>
</el-col>
</el-row>
<el-row>
<el-col :span="24">
<el-form-item label="项目名称" prop="projectName">
<el-input class="!w-265px" placeholder="项目名称" v-model="formData.projectName" disabled />
</el-form-item>
</el-col>
</el-row>
</el-col>
<el-col :span="6">
<el-row>
<el-col :span="24">
<el-form-item label="项目编号" prop="projectCode">
<el-input class="!w-265px" v-model="formData.projectCode" placeholder="项目编号" disabled />
</el-form-item>
</el-col>
</el-row>
<el-row>
<el-col :span="24">
<el-form-item label="单据状态" prop="status">
<el-select v-model="formData.status" placeholder="单据状态" clearable class="!w-265px" disabled>
<el-option v-for="dict in getIntDictOptions(DICT_TYPE.HELI_PROJECT_MATERIAL_PLAN_STATUS)"
:key="dict.value" :label="dict.label" :value="dict.value" />
</el-select>
</el-form-item>
</el-col>
</el-row>
</el-col>
</el-row>
</el-col>
</el-row>
</el-card>
<!-- 物料信息 -->
<el-card class="hl-card-info">
<template #header>
<div class="hl-card-info-icona"></div><span class="hl-card-info-text">物料信息</span>
</template>
<el-row>
<el-col>
<el-card class="hl-incard">
<el-col>
<el-button class="hl-addbutton" type="primary" size="large" @click="onAddItem"></el-button>
</el-col>
<el-form ref="matSubFormRef" :model="formData.matItemDOList" :rules="subFormRules"
v-loading="subFormLoading" label-width="0">
<el-table :data="formData.matItemDOList" class="hl-table">
<el-table-column type="index" label="序号" :width="80" />
<el-table-column prop="matCode" label="物料编码" min-width="120" align="center" />
<el-table-column prop="matId" min-width="140" align="center">
<template #header> <span class="hl-table_header">*</span>物料名称 </template>
<template #default="scope">
<el-form-item :prop="`${scope.$index}.matId`" :rules="subFormRules.matId" class="mb-0px!">
<el-select v-model="scope.row.matId" placeholder="物料名称" :remote-method="remoteMatNameSearch"
remote-show-suffix remote clearable reserve-keyword filterable :loading="matSelectLoading"
@change="(val) => handleMatName(scope, val)" class="!w-180px">
<el-option v-for="item in matList" :key="item.id" :label="item.name" :value="item.id" />
</el-select>
</el-form-item>
</template>
</el-table-column>
<el-table-column prop="matType" label="物料类型" min-width="120" align="center">
<template #default="scope">
<dict-tag :type="DICT_TYPE.HELI_MATERIAL_TYPE" :value="scope.row.matType"
v-if="scope.row.matType ? true : false" />
</template>
</el-table-column>
<el-table-column prop="matSpec" label="规格/型号" min-width="120" align="center" />
<el-table-column prop="matUnit" label="系统单位" min-width="120" align="center">
<template #default="scope">
<dict-tag :type="DICT_TYPE.HELI_MATERIAL_UNIT" :value="scope.row.matUnit"
v-if="scope.row.matUnit ? true : false" />
</template>
</el-table-column>
<el-table-column prop="requireAmount" min-width="120" align="center">
<template #header><span class="hl-table_header">*</span>需求数量</template>
<template #default="scope">
<el-input v-model="scope.row.requireAmount" />
</template>
</el-table-column>
<el-table-column min-width="150" align="center">
<template #header> <span class="hl-table_header">*</span>需求到货日期 </template>
<template #default="{ row, $index }">
<el-form-item :prop="`${$index}.requireArriveTime`" class="mb-0px!">
<el-date-picker class="!w-265px" v-model="row.requireArriveTime" type="date" value-format="x"
placeholder="需求到货日期" />
</el-form-item>
</template>
</el-table-column>
<el-table-column min-width="150" align="center">
<template #header><span class="hl-table_header">*</span>子项目编号</template>
<template #default="{ row, $index }">
<el-form-item :prop="`${$index}.projectSubId`" class="mb-0px!">
<el-select class="!w-265px" v-model="row.projectSubId" filterable>
<el-option v-for="dict in formData.projectOrderSubs" :key="dict.projectSubId"
:label="dict.projectSubCode" :value="dict.projectSubId" />
</el-select>
</el-form-item>
</template>
</el-table-column>
<el-table-column prop="description" min-width="180" label="备注" align="center">
<template #default="scope">
<el-input v-model="scope.row.description" />
</template>
</el-table-column>
<el-table-column label="操作" align="center" width="240">
<template #default="scope">
<el-button link type="danger" size="small" @click.prevent="handleDelete2(scope.$index)">
删除
</el-button>
</template>
</el-table-column>
</el-table>
</el-form>
</el-card>
</el-col>
</el-row>
</el-card>
<!-- 附件信息 -->
<el-card class="hl-card-info">
<template #header>
<div class="hl-card-info-icona"></div><span class="hl-card-info-text">附件信息</span>
</template>
<el-row>
<el-col>
<el-card class="hl-incard">
<el-col>
<el-upload ref="matUploadRef" :file-list="matUploadFiles" multiple :limit="10" :action="uploadUrl"
:headers="{
Authorization: 'Bearer ' + getAccessToken(),
'tenant-id': getTenantId()
}" name="files" :show-file-list="false" :auto-upload="false" :data="matUploadData"
:on-change="matUploadChange" :on-error="UpError" class="upload-file-uploader">
<el-button type="primary">
<Icon icon="ep:upload-filled" />上传
</el-button>
</el-upload>
</el-col>
<el-table :data="formData.attachments" class="hl-table">
<el-table-column prop="name" label="文件名称" align="center">
<!-- <template #default="scope">
<a :href="scope.row.url" target="_blank" style="color: #409eff">{{ scope.row.name }} </a>
</template> -->
</el-table-column>
<el-table-column prop="createTime" align="center" label="上传日期" :formatter="dateFormatter" />
<el-table-column label="操作" align="center">
<template #default="scope">
<el-button link type="danger" size="small"
@click="handleDeleteAttachment(scope.$index, scope.row.businessFileType)">
删除
</el-button>
<el-button link type="primary" size="small"
@click="downloadAttachment(scope.row.name, scope.row.url)">
下载
</el-button>
</template>
</el-table-column>
</el-table>
</el-card>
</el-col>
</el-row>
</el-card>
<!-- 系统信息 -->
<el-card class="hl-card-info">
<template #header>
<div class="hl-card-info-icona"></div><span class="hl-card-info-text">系统信息</span>
</template>
<el-row justify="center">
<el-col :span="8">
<el-form-item prop="creator" label="创建人">
{{ userList.find((user) => user.id == formData.creator)?.nickname }}
</el-form-item>
</el-col>
<el-col :span="8">
<el-form-item prop="createTime" label="创建时间">
{{ formatDate(formData.createTime, 'YYYY-MM-DD HH:mm') }}
</el-form-item>
</el-col>
</el-row>
<el-row justify="center">
<el-col :span="8">
<el-form-item prop="submitUserId" label="送审人">
{{ userList.find((user) => user.id == formData.submitUserId)?.nickname }}
</el-form-item>
</el-col>
<el-col :span="8">
<el-form-item prop="submitTime" label="出库时间">
{{ formatDate(formData.submitTime, 'YYYY-MM-DD HH:mm') }}
</el-form-item>
</el-col>
</el-row>
<el-row justify="center">
<el-col :span="8">
<el-form-item prop="auditor" label="审核人">
{{ userList.find((user) => user.id == formData.auditor)?.nickname }}
</el-form-item>
</el-col>
<el-col :span="8">
<el-form-item prop="auditTime" label="审核时间">
{{ formatDate(formData.auditTime, 'YYYY-MM-DD HH:mm') }}
</el-form-item>
</el-col>
</el-row>
</el-card>
</el-form>
<div class="text-center hl-footer">
<el-button @click="() => router.back()" size="large"> </el-button>
<el-button @click="deleteForm" type="danger" size="large"> </el-button>
<el-button @click="submitForm" type="primary" size="large"> </el-button>
<el-button @click="saveForm" type="success" size="large"> </el-button>
</div>
</el-card>
<ProjectPlanDialog ref="projectPlanDialog" @success="handleSelectedProjectPlan" />
</template>
<script setup lang="ts">
import { getIntDictOptions, DICT_TYPE } from '@/utils/dict'
import * as MaterialPlanApi from '@/api/heli/materialplan'
import * as MaterialPlanDetailApi from '@/api/heli/materialplandetail'
import * as PlanApi from '@/api/heli/plan'
import * as PlanSubApi from '@/api/heli/plansub'
import * as ProjectOrderApi from '@/api/heli/projectorder'
import * as UserApi from '@/api/system/user'
import * as MaterialApi from '@/api/heli/material'
import { deleteFile, downloadFile, getFilePage } from '@/api/infra/file'
import download from '@/utils/download'
import { getAccessToken, getTenantId } from '@/utils/auth'
import { dateFormatter, formatDate } from '@/utils/formatTime'
import ProjectPlanDialog from '@/views/heli/materialplan/ProjectPlanDialog.vue'
const { t } = useI18n() //
const message = useMessage() //
const { query } = useRoute()
const dialogVisible = ref(false) //
const formLoading = ref(false) // 12
const formData = ref({
id: undefined,
projectMaterialPlanNo: undefined,
projectId: undefined,
projectPlanId: undefined,
projectPlanNo: undefined,
projectCode: undefined,
auditor: undefined,
createTime: new Date(),
status: undefined,
description: undefined,
matItemDOList: [],
attachments: []
})
const formRules = reactive({
projectPlanId: [{ required: true, message: '生产计划单号不能为空', trigger: 'blur' }],
})
const subFormRules = reactive({
matCode: [{ required: true, message: '物料编码不能为空', trigger: 'blur' }],
requireAmount: [{ required: true, message: '需求数量不能为空', trigger: 'blur' }],
requireArriveTime: [{ required: true, message: '需求到货日期不能为空', trigger: 'blur' }],
projectSubId: [{ required: true, message: '子项目编号不能为空', trigger: 'blur' }],
})
const formRef = ref() // Ref
const subFormRef = ref() // Ref
// ==================== =======================================
const uploadUrl = ref(import.meta.env.VITE_UPLOAD_BATCH_URL)
const matUploadRef = ref()
const matUploadFiles = ref<UploadUserFile[]>([])
const matUploadData = ref({
businessType: 'MATERIALPLAN',
businessId: formData.value.id,
businessFileType: ''
})
const matUploadChange = (file, files) => {
matUploadFiles.value = files
refreshAttachments(files, 'MATERIALPLAN')
}
const failedAttachments = ref<UploadUserFile[]>([])
const failedAttachmentsName = ref()
const UpError = (err, file, fileList) => {
//
if (err) {
// failedAttachments.value
failedAttachments.value.push(file)
failedAttachmentsName.value = failedAttachments.value.map((value) => value.name)
}
}
const openerror = () => {
setTimeout(() => {
if (failedAttachmentsName.value.length > 0) {
//
ElMessageBox.alert(
// 使
`文件名为:${failedAttachmentsName.value.join(' / ')}上传失败`,
`文件格式不正确或网络问题 请您稍后再试`,
{
dangerouslyUseHTMLString: false,
confirmButtonText: '知道了',
center: true
}
)
}
}, 1000)
}
const refreshAttachments = (files, type) => {
formData.value.attachments = formData.value.attachments.filter((value) => value.id)
//
const newFiles = files.filter(
(file) => !formData.value.attachments.some((att) => att.name === file.name)
)
for (let i = 0; i < newFiles.length; i++) {
let file = newFiles[i]
file.businessFileType = type
file.createTime = new Date()
formData.value.attachments.push(file)
}
//
formData.value.attachments.sort((v1, v2) => v1.createTime - v2.createTime)
}
//
const handleDeleteAttachment = async (index, type) => {
const deletedAttachments = formData.value.attachments.splice(index, 1)
for (let i = 0; i < deletedAttachments.length; i++) {
const attachment = deletedAttachments[i]
if (attachment.id) {
//
await deleteFile(attachment.id)
}
//
matUploadFiles.value = matUploadFiles.value.filter((file1) => {
return file1.name != attachment.name || file1.businessFileType != type
})
}
}
//
const downloadAttachment = async (name, url) => {
if (url) {
const data = await downloadFile(url)
download.any(data, name)
}
}
// ==================== =======================================
//
const getMatList = async (name) => {
//
let matParams = {
pageNo: 1,
pageSize: 10,
status: '1'
}
if (name.length > 0) {
matParams.name = name
}
const dataMat = await MaterialApi.getMaterialPage(matParams)
matList.value = dataMat.list
}
const matList = ref<MaterialApi.MaterialVO[]>([]) //
const matSelectLoading = ref(false)
const remoteMatNameSearch = async (name) => {
matSelectLoading.value = true
//
await getMatList(name)
matSelectLoading.value = false
}
const handleMatName = async (scope, matid) => {
scope.row.matId = matList.value.find((item) => item.id === matid)?.id
scope.row.matName = matList.value.find((item) => item.id === matid)?.name
scope.row.matCode = matList.value.find((item) => item.id === matid)?.code
scope.row.matSpec = matList.value.find((item) => item.id === matid)?.spec
scope.row.matType = matList.value.find((item) => item.id === matid)?.materialType
scope.row.matUnit = matList.value.find((item) => item.id === matid)?.unit
}
//
const onAddItem = () => {
const newData = {
//
stockId: 0,
matId: '',
matName: '',
matCode: '',
matType: '',
matSpec: '',
matUnit: '',
requireAmount: '',
requireArriveTime: '',
projectSubId: '',
description: ''
}
formData.value.matItemDOList.push(newData)
}
//
const handleDelete2 = (index: number) => {
formData.value.matItemDOList.splice(index, 1)
}
const handleInitPlanSub = async () => {
//
formData.value.projectOrderSubs =
await ProjectOrderApi.getProjectOrderSubListByProjectOrderId(formData.value.projectId)
//
const queryParams = reactive({
pageNo: 1,
pageSize: 99,
projectPlanId: query.id
})
formData.value.projectPlanSubs =
(await PlanSubApi.getPlanSubPage(queryParams)).list
formData.value.projectOrderSubs.forEach(item => {
if (formData.value.projectPlanSubs.filter(sub => sub.projectSubId == item.id).length > 0) {
var subTemp = formData.value.projectPlanSubs.find(sub => sub.projectSubId == item.id)
item.projectSubId = subTemp.projectSubId
item.projectSubCode = subTemp.projectSubCode
}
})
}
//
const saveMaterials = async () =>{
formData.value.matItemDOList.forEach(item => {
var subData = item as unknown as MaterialPlanDetailApi.MaterialPlanDetailVO
subData.materialId = item.matId
subData.projectMaterialPlanId = formData.value.id
if (subData.id == undefined) {
MaterialPlanDetailApi.createMaterialPlanDetail(subData)
} else {
MaterialPlanDetailApi.updateMaterialPlanDetail(subData)
}
})
}
//
const submitForm = async () => {
//
formLoading.value = true
try {
const data = formData.value as unknown as MaterialPlanApi.MaterialPlanVO
await MaterialPlanApi.updateMaterialPlan(data)
//
await saveMaterials()
//formData.value.matItemDOList
if (formData.value.attachments != undefined && formData.value.attachments.length > 0) {
//
matUploadData.value.businessId = formData.value.id
await matUploadRef.value!.submit()
}
message.success(t('common.updateSuccess'))
dialogVisible.value = false
//
emit('success')
} finally {
formLoading.value = false
}
}
const userList = ref<UserApi.UserVO[]>([]) //
const planInit = ref()
const projectInit = ref()
const queryParams = reactive({
pageNo: 1,
pageSize: 99,
projectMaterialPlanId: query.id,
})
//
onMounted(async () => {
//
formData.value = await MaterialPlanApi.getMaterialPlan(query.id)
//
planInit.value = await PlanApi.getPlan(formData.value.projectPlanId)
//
projectInit.value = await ProjectOrderApi.getProjectOrder(formData.value.projectId)
formData.value.planNo = planInit.value.planNo
formData.value.projectName = projectInit.value.projectName
formData.value.projectCode = projectInit.value.code
//
formData.value.matItemDOList = (await MaterialPlanDetailApi.getMaterialPlanDetailPage(queryParams)).list
formData.value.matItemDOList.forEach(item=>{
matList.value.push({id:item.matId,name:item.matName})
})
//
await handleInitPlanSub()
//
let attParams = {
pageNo: 1,
pageSize: 99,
businessId: query.id,
businessType: 'MATERIALPLAN'
}
formData.value.attachments = (await getFilePage(attParams)).list
//
userList.value = await UserApi.getSimpleUserList()
})
</script>

@ -155,7 +155,7 @@ CREATE TABLE `project_material_plan_detail` (
`project_material_plan_id` bigint(20) NOT NULL COMMENT '物料需求采购计划id', `project_material_plan_id` bigint(20) NOT NULL COMMENT '物料需求采购计划id',
`material_id` bigint(20) NOT NULL COMMENT '物料id', `material_id` bigint(20) NOT NULL COMMENT '物料id',
`project_sub_id` bigint(20) DEFAULT NULL COMMENT '子项目编号', `project_sub_id` bigint(20) DEFAULT NULL COMMENT '子项目编号',
`require_amount` bigint(20) DEFAULT NULL COMMENT '需求数量', `require_amount` decimal(11,2) DEFAULT NULL COMMENT '需求数量',
`require_arrive_time` datetime DEFAULT NULL COMMENT '需求到货日期', `require_arrive_time` datetime DEFAULT NULL COMMENT '需求到货日期',
`description` varchar(255) DEFAULT NULL COMMENT '备注', `description` varchar(255) DEFAULT NULL COMMENT '备注',
`creator` varchar(64) DEFAULT '' COMMENT '创建者', `creator` varchar(64) DEFAULT '' COMMENT '创建者',

Loading…
Cancel
Save