库存出入库 物料信息 表格必填示意

pull/1/head
qiuhongwu 9 months ago
parent dbbacc5853
commit e1f1c0f754

@ -1,10 +1,17 @@
<template>
<!-- 入库 -->
<el-card class="hl-card">
<template #header>
<span v-text="dialogTitle"></span>
</template>
<el-form ref="formRef" :model="formData" :rules="formRules" label-width="100px" v-loading="formLoading"
v-bind:disabled="isShowBtnOther">
<el-form
ref="formRef"
:model="formData"
:rules="formRules"
label-width="100px"
v-loading="formLoading"
v-bind:disabled="isShowBtnOther"
>
<!-- 基础信息 -->
<el-card class="hl-card-info">
<template #header>
@ -23,22 +30,34 @@
<el-col :span="24">
<el-form-item prop="stockInType" label="入库类型">
<el-select v-model="formData.stockInType" clearable style="width: 100%">
<el-option v-for="dict in getIntDictOptions(DICT_TYPE.HELI_STORAGE_IN_TYPE)" :key="dict.value"
:label="dict.label" :value="dict.value" />
<el-option
v-for="dict in getIntDictOptions(DICT_TYPE.HELI_STORAGE_IN_TYPE)"
:key="dict.value"
:label="dict.label"
:value="dict.value"
/>
</el-select>
</el-form-item>
</el-col>
</el-row>
</el-col>
<el-col :span="8">
<el-row>
<el-col :span="24">
<el-form-item prop="industry" label="单据状态">
<el-select v-model="formData.status" placeholder="下拉选择" clearable class="!w-700px" disabled>
<el-option v-for="dict in getIntDictOptions(DICT_TYPE.HELI_STORAGE_STATUS)" :key="dict.value"
:label="dict.label" :value="dict.value" />
<el-select
v-model="formData.status"
placeholder="下拉选择"
clearable
class="!w-700px"
disabled
>
<el-option
v-for="dict in getIntDictOptions(DICT_TYPE.HELI_STORAGE_STATUS)"
:key="dict.value"
:label="dict.label"
:value="dict.value"
/>
</el-select>
</el-form-item>
</el-col>
@ -50,7 +69,6 @@
</el-form-item>
</el-col>
</el-row>
</el-col>
<el-col :span="8">
<el-row>
@ -62,21 +80,35 @@
</el-row>
<el-row>
<el-col :span="24">
<el-form-item prop="whId" label="入库仓库" required>
<el-select v-model="formData.whId" placeholder="下拉选择" clearable class="!w-400px" @change="handleWh">
<el-option v-for="dict in warehouseList" :key="dict.id" :label="dict.whName" :value="dict.id" />
<el-form-item prop="whId" label="入库仓库">
<el-select
v-model="formData.whId"
placeholder="下拉选择"
clearable
class="!w-400px"
@change="handleWh"
>
<el-option
v-for="dict in warehouseList"
:key="dict.id"
:label="dict.whName"
:value="dict.id"
/>
</el-select>
</el-form-item>
</el-col>
</el-row>
</el-col>
</el-row>
<el-row>
<el-col :span="24">
<el-form-item label="备注" prop="description">
<el-input type="textarea" v-model="formData.description" show-word-limit maxlength="200" />
<el-input
type="textarea"
v-model="formData.description"
show-word-limit
maxlength="200"
/>
</el-form-item>
</el-col>
</el-row>
@ -90,24 +122,51 @@
<el-col>
<el-card class="hl-incard">
<el-col>
<el-button class="hl-addbutton" type="primary" size="large" @click="onAddItem"></el-button>
<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 prop="cid" label="序号" :width="80" />
<el-table-column prop="matId" label="物料编码">
<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 prop="cid" label="序号" min-width="80" align="center" fixed />
<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="remoteMatCodeSearch"
remote-show-suffix remote clearable reserve-keyword filterable :loading="matSelectLoading"
@change="(val) => handleMatCode(scope, val)" class="!w-180px">
<el-option v-for="item in matList" :key="item.id" :label="item.code" :value="item.id" />
<el-form-item
:prop="`${scope.$index}.matId`"
:rules="subFormRules.matId"
class="mb-0px!"
>
<el-select
v-model="scope.row.matId"
placeholder="物料编码"
:remote-method="remoteMatCodeSearch"
remote-show-suffix
remote
clearable
reserve-keyword
filterable
:loading="matSelectLoading"
@change="(val) => handleMatCode(scope, val)"
class="!w-180px"
>
<el-option
v-for="item in matList"
:key="item.id"
:label="item.code"
:value="item.id"
/>
</el-select>
</el-form-item>
</template>
</el-table-column>
<el-table-column prop="matName" label="物料名称">
<el-table-column prop="matName" label="物料名称" min-width="120" align="center">
<!-- <template #default="scope">
<el-input v-model="scope.row.matName"
:disabled="!scope.row.editable" />
@ -120,66 +179,108 @@
</template> -->
</el-table-column>
<el-table-column prop="matType" label="物料类型">
<el-table-column prop="matType" label="物料类型" align="center" min-width="120">
<template #default="scope">
<dict-tag :type="DICT_TYPE.HELI_MATERIAL_TYPE" :value="scope.row.matType"
v-if="scope.row.matType ? true : false" />
<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="规格/型号" />
<el-table-column prop="matUnit" label="系统单位">
<el-table-column
prop="matSpec"
label="规格/型号"
align="center"
min-width="120"
/>
<el-table-column prop="matUnit" label="系统单位" align="center" min-width="120">
<template #default="scope">
<dict-tag :type="DICT_TYPE.HELI_MATERIAL_UNIT" :value="scope.row.matUnit"
v-if="scope.row.matUnit ? true : false" />
<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="rgId" width="140" label="入库库区" required>
<el-table-column prop="rgId" align="center" min-width="120">
<template #header> <span class="hl-table_header">*</span> 入库库区 </template>
<template #default="scope">
<el-form-item :prop="`${scope.$index}.rgId`" :rules="subFormRules.rgId" class="mb-0px!">
<el-select v-model="scope.row.rgId" placeholder="" style="width: 100%" @change="handleRg(scope)">
<el-option v-for="dict in rgList" :key="dict.id" :label="dict.rgName" :value="dict.id" />
<el-form-item
:prop="`${scope.$index}.rgId`"
:rules="subFormRules.rgId"
class="mb-0px!"
>
<el-select
v-model="scope.row.rgId"
placeholder=""
style="width: 100%"
@change="handleRg(scope)"
>
<el-option
v-for="dict in rgList"
:key="dict.id"
:label="dict.rgName"
:value="dict.id"
/>
</el-select>
</el-form-item>
</template>
</el-table-column>
<el-table-column prop="pnId" width="140" label="入库库位" required>
<el-table-column prop="pnId" align="center" min-width="120">
<template #header> <span class="hl-table_header">*</span> 入库库位 </template>
<template #default="scope">
<el-form-item :prop="`${scope.$index}.pnId`" :rules="subFormRules.pnId" class="mb-0px!">
<el-form-item
:prop="`${scope.$index}.pnId`"
:rules="subFormRules.pnId"
class="mb-0px!"
>
<el-select v-model="scope.row.pnId" placeholder="" style="width: 100%">
<el-option v-for="dict in scope.row.pnlist" :key="dict.id" :label="dict.pnName"
:value="dict.id" />
<el-option
v-for="dict in scope.row.pnlist"
:key="dict.id"
:label="dict.pnName"
:value="dict.id"
/>
</el-select>
</el-form-item>
</template>
</el-table-column>
<el-table-column prop="storageOkQty" width="120" label="入库数量" required>
<el-table-column prop="storageOkQty" align="center" min-width="120">
<template #header> <span class="hl-table_header">*</span> 入库数量 </template>
<template #default="scope">
<el-form-item :prop="`${scope.$index}.storageOkQty`" :rules="subFormRules.storageOkQty"
class="mb-0px!">
<el-form-item
:prop="`${scope.$index}.storageOkQty`"
:rules="subFormRules.storageOkQty"
class="mb-0px!"
>
<el-input v-model="scope.row.storageOkQty" />
</el-form-item>
</template>
</el-table-column>
<el-table-column prop="lotNo" width="120" label="批次号">
<el-table-column prop="lotNo" label="批次号" align="center" min-width="120">
<template #default="scope">
<el-input v-model="scope.row.lotNo" />
</template>
</el-table-column>
<el-table-column prop="projectNo" width="120" label="子项目编号">
<el-table-column
prop="projectNo"
label="子项目编号"
align="center"
min-width="120"
>
<template #default="scope">
<el-input v-model="scope.row.projectNo" />
</template>
</el-table-column>
<el-table-column prop="description" width="150" label="备注">
<el-table-column prop="description" label="备注" align="center" min-width="180" >
<template #default="scope">
<el-input v-model="scope.row.description" />
</template>
</el-table-column>
<el-table-column label="操作" align="center" width="240">
<el-table-column label="操作" align="center" min-width="120" fixed="right">
<template #default="scope">
<!-- <el-button v-if="!scope.row.editable" type="primary" size="small" link
@click="handleEdit(scope.$index)">
@ -190,8 +291,12 @@
</el-button>
<el-button link type="primary" @click="handlefuke(scope.$index, scope.row)">复制</el-button> -->
<el-button link type="danger" size="small" @click.prevent="handleDelete2(scope.$index)"
v-bind:disabled="isShowBtnOther">
<el-button
link
type="danger"
@click.prevent="handleDelete2(scope.$index)"
v-bind:disabled="isShowBtnOther"
>
删除
</el-button>
</template>
@ -211,13 +316,24 @@
<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"
class="upload-file-uploader">
<el-button type="primary">
<Icon icon="ep:upload-filled" />上传
</el-button>
<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"
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">
@ -227,18 +343,33 @@
</template> -->
</el-table-column>
<el-table-column prop="createTime" align="center" label="上传日期" :formatter="dateFormatter" />
<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"
<el-button
link
type="danger"
size="small"
@click="handleDeleteAttachment(scope.$index, scope.row.businessFileType)"
v-bind:disabled="isShowBtnOther">
v-bind:disabled="isShowBtnOther"
>
删除
</el-button>
<el-button link type="primary" size="small" v-if="isShow"
@click="downloadAttachment(scope.row.name, scope.row.url)">
下载 </el-button>
<el-button
link
type="primary"
size="small"
v-if="isShow"
@click="downloadAttachment(scope.row.name, scope.row.url)"
>
下载
</el-button>
</template>
</el-table-column>
</el-table>
@ -292,41 +423,58 @@
</el-form>
<div class="text-center hl-footer">
<el-button @click="() => router.go(-1)" size="large"> </el-button>
<el-button @click="submitForm" v-if="isShowBtnGroup" type="success" :disabled="formLoading" size="large">
</el-button>
<el-button @click="handleStatus(2)" v-if="isShowBtnGroup" type="primary" :disabled="formLoading" size="large">
</el-button>
<el-button @click="handleStatus(3)" v-if="isShowBtnCancel" type="danger" :disabled="formLoading" size="large">
</el-button>
<el-button
@click="submitForm"
v-if="isShowBtnGroup"
type="success"
:disabled="formLoading"
size="large"
> </el-button
>
<el-button
@click="handleStatus(2)"
v-if="isShowBtnGroup"
type="primary"
:disabled="formLoading"
size="large"
> </el-button
>
<el-button
@click="handleStatus(3)"
v-if="isShowBtnCancel"
type="danger"
:disabled="formLoading"
size="large"
> </el-button
>
</div>
</el-card>
</template>
<script setup lang="ts">
import { ref } from 'vue'
import { useRoute } from "vue-router"
import { dateFormatter, formatDate } from "@/utils/formatTime"
import { useRoute } from 'vue-router'
import { dateFormatter, formatDate } from '@/utils/formatTime'
import type { UploadUserFile } from 'element-plus'
import { getIntDictOptions, DICT_TYPE } from '@/utils/dict'
import * as StorageApi from '@/api/heli/storage'
import * as StorageMatApi from '@/api/heli/storagemat'
import { getAccessToken, getTenantId } from "@/utils/auth"
import { getAccessToken, getTenantId } from '@/utils/auth'
import { useUserStore } from '@/store/modules/user'
import * as MaterialApi from '@/api/heli/material'
import * as WarehouseApi from '@/api/heli/warehouse'
import * as RgApi from '@/api/heli/rg'
import * as PnApi from '@/api/heli/pn'
import { deleteFile, downloadFile, getFilePage } from "@/api/infra/file"
import download from "@/utils/download"
import * as UserApi from "@/api/system/user";
import { deleteFile, downloadFile, getFilePage } from '@/api/infra/file'
import download from '@/utils/download'
import * as UserApi from '@/api/system/user'
const reload = inject('reload')
const { t } = useI18n() //
const message = useMessage() //
const { query } = useRoute()
const router = useRouter();
const router = useRouter()
const isShow = ref(false)
const dialogTitle = ref('') //
@ -367,11 +515,9 @@ const subFormRules = reactive({
matId: [{ required: true, message: '物料不能为空', trigger: 'blur' }],
rgId: [{ required: true, message: '库区不能为空', trigger: 'blur' }],
pnId: [{ required: true, message: '库位不能为空', trigger: 'blur' }],
storageOkQty: [{ required: true, message: '入库数量不能为空', trigger: 'blur' }],
storageOkQty: [{ required: true, message: '入库数量不能为空', trigger: 'blur' }]
})
const handleStatus = (async (num) => {
const handleStatus = async (num) => {
formData.value.status = num
const dataUpdate = formData.value as unknown as StorageApi.StorageVO
@ -388,37 +534,41 @@ const handleStatus = (async (num) => {
switch (num) {
case 1:
isShowBtnGroup.value = true;
isShowBtnCancel.value = false;
isShowBtnGroup.value = true
isShowBtnCancel.value = false
break
case 2:
isShowBtnGroup.value = false;
isShowBtnCancel.value = true;
isShowBtnGroup.value = false
isShowBtnCancel.value = true
break
case 3:
isShowBtnGroup.value = false;
isShowBtnCancel.value = false;
break;
isShowBtnGroup.value = false
isShowBtnCancel.value = false
break
default:
break
}
//
if (query.type === 'review') {
isShowBtnGroup.value = false;
isShowBtnCancel.value = false;
isShowBtnOther.value = true;
isShowBtnGroup.value = false
isShowBtnCancel.value = false
isShowBtnOther.value = true
}
reload();
})
reload()
}
const userList = ref<UserApi.UserVO[]>([]) //
// ==================== =======================================
const uploadUrl = ref(import.meta.env.VITE_UPLOAD_BATCH_URL)
const matUploadRef = ref();
const matUploadFiles = ref<UploadUserFile[]>([]);
const matUploadData = ref({ businessType: 'STORAGE', businessId: formData.value.id, businessFileType: 'MATERIAL' })
const matUploadRef = ref()
const matUploadFiles = ref<UploadUserFile[]>([])
const matUploadData = ref({
businessType: 'STORAGE',
businessId: formData.value.id,
businessFileType: 'MATERIAL'
})
const matUploadChange = (file, files) => {
matUploadFiles.value = files;
matUploadFiles.value = files
refreshAttachments(files, 'MATERIAL')
}
@ -427,28 +577,28 @@ const refreshAttachments = (files, type) => {
return value.id
})
for (let i = 0; i < files.length; i++) {
let file = files[i];
file.businessFileType = type;
file.createTime = new Date();
formData.value.attachments.push(file);
let file = files[i]
file.businessFileType = type
file.createTime = new Date()
formData.value.attachments.push(file)
}
//
formData.value.attachments.sort((v1, v2) => {
return (v1.createTime - v2.createTime) > 0
return v1.createTime - v2.createTime > 0
})
}
//
const handleDeleteAttachment = async (index, type) => {
const deletedAttachments = formData.value.attachments.splice(index, 1);
const deletedAttachments = formData.value.attachments.splice(index, 1)
for (let i = 0; i < deletedAttachments.length; i++) {
const attachment = deletedAttachments[i];
const attachment = deletedAttachments[i]
if (attachment.id) {
//
await deleteFile(attachment.id);
await deleteFile(attachment.id)
}
//
matUploadFiles.value = matUploadFiles.value.filter(file1 => {
return file1.name != attachment.name || file1.businessFileType != type;
matUploadFiles.value = matUploadFiles.value.filter((file1) => {
return file1.name != attachment.name || file1.businessFileType != type
})
}
}
@ -456,7 +606,7 @@ const handleDeleteAttachment = async (index, type) => {
const downloadAttachment = async (name, url) => {
if (url) {
const data = await downloadFile(url)
download.any(data, name);
download.any(data, name)
}
}
// ==================== =======================================
@ -480,18 +630,16 @@ const submitForm = async () => {
try {
const data = formData.value as unknown as StorageApi.StorageVO
if (query.type === 'create') {
//
storageid.value = await StorageApi.createStorage(data)
commonResult = 'common.createSuccess'
} else {
storageid.value = data.id
await StorageApi.updateStorage(data)
commonResult = 'common.updateSuccess'
}
//
formData.value.matItemDOList.forEach(item => {
formData.value.matItemDOList.forEach((item) => {
item.stockId = storageid.value
item.whId = formData.value.whId
})
@ -506,10 +654,8 @@ const submitForm = async () => {
message.success(t(commonResult))
//
reload();
reload()
} finally {
formLoading.value = false
}
@ -539,7 +685,6 @@ const onAddItem = () => {
}
matCount = matCount + 1
formData.value.matItemDOList.push(newData)
}
//
@ -553,7 +698,7 @@ const warehouseList = ref([])
var rgList = ref([])
//
var pnList = ref([])
const handleWh = (async (wid) => {
const handleWh = async (wid) => {
//-------------------
const queryParamsRg = reactive({
pageNo: 1,
@ -566,14 +711,14 @@ const handleWh = (async (wid) => {
pnList.value = []
rgList.value = dataRg.list
formData.value.matItemDOList.forEach(item => {
formData.value.matItemDOList.forEach((item) => {
item.rgId = ''
item.pnId = ''
item.pnlist.value = []
})
//-------------------
})
const handleRg = (async (scope) => {
}
const handleRg = async (scope) => {
//-------------------
const queryParamsRPn = reactive({
pageNo: 1,
@ -585,10 +730,10 @@ const handleRg = (async (scope) => {
scope.row.pnid = ''
scope.row.pnlist = dataPn.list
//-------------------
})
}
const matList = ref<MaterialApi.MaterialVO[]>([]) //
const matSelectLoading = ref(false);
const matSelectLoading = ref(false)
const remoteMatCodeSearch = async (code) => {
matSelectLoading.value = true
//
@ -596,17 +741,15 @@ const remoteMatCodeSearch = async (code) => {
pageNo: 1,
pageSize: 10,
code: code,
status: "1"
status: '1'
}
const dataMat = await MaterialApi.getMaterialPage(matParams)
matList.value = []
matList.value = dataMat.list
matSelectLoading.value = false
}
const handleMatCode = async (scope, matid) => {
if (matid) {
const matVo = await MaterialApi.getMaterial(scope.row.matId)
scope.row.matId = matVo.id
@ -630,23 +773,21 @@ const isShowBtnOther = ref(false)
const btnWhClickable = ref(false)
/** 初始化 **/
onMounted(async () => {
//
let matParams = {
pageNo: 1,
pageSize: 99,
status: "1"
status: '1'
}
const dataMat = await MaterialApi.getMaterialPage(matParams)
matList.value = []
matList.value = dataMat.list
dialogTitle.value = t('action.' + query.type)
dialogTitle.value = query.type === 'review' ? '查看' : dialogTitle.value
isShow.value = query.type == "create" ? false : true
isShow.value = query.type == 'create' ? false : true
//-------------------
const data = await WarehouseApi.getWarehouseSimpList()
@ -658,25 +799,25 @@ onMounted(async () => {
switch (formData.value.status) {
case 1:
isShowBtnGroup.value = true;
isShowBtnCancel.value = false;
isShowBtnGroup.value = true
isShowBtnCancel.value = false
break
case 2:
isShowBtnGroup.value = false;
isShowBtnCancel.value = true;
isShowBtnGroup.value = false
isShowBtnCancel.value = true
break
case 3:
isShowBtnGroup.value = false;
isShowBtnCancel.value = false;
break;
isShowBtnGroup.value = false
isShowBtnCancel.value = false
break
default:
break
}
//
if (query.type === 'review') {
isShowBtnGroup.value = false;
isShowBtnCancel.value = false;
isShowBtnOther.value = true;
isShowBtnGroup.value = false
isShowBtnCancel.value = false
isShowBtnOther.value = true
}
//
@ -717,7 +858,7 @@ onMounted(async () => {
})
const matVos = await MaterialApi.getMaterialPage(queryParamsMat2)
formData.value.matItemDOList.forEach(item => {
formData.value.matItemDOList.forEach((item) => {
item.cid = matCount
item.matId = matVos.list.find((record) => record.id === item.matId)?.id
//item.matCode = matVos.list.find( (record) => record.id === item.matId)?.id
@ -729,7 +870,6 @@ onMounted(async () => {
matCount = matCount + 1
})
//
let attParams = {
pageNo: 1,
@ -737,12 +877,11 @@ onMounted(async () => {
businessId: query.id,
businessType: 'STORAGE'
}
formData.value.attachments = (await getFilePage(attParams)).list;
formData.value.attachments = (await getFilePage(attParams)).list
}
//
userList.value = await UserApi.getSimpleUserList()
})
</script>
<style>

@ -1,10 +1,17 @@
<template>
<!-- 出库 -->
<el-card class="hl-card">
<template #header>
<span v-text="dialogTitle"></span>
</template>
<el-form ref="formRef" :model="formData" :rules="formRules" label-width="100px" v-loading="formLoading"
v-bind:disabled="isShowBtnOther">
<el-form
ref="formRef"
:model="formData"
:rules="formRules"
label-width="100px"
v-loading="formLoading"
v-bind:disabled="isShowBtnOther"
>
<!-- 基础信息 -->
<el-card class="hl-card-info">
<template #header>
@ -23,21 +30,34 @@
<el-col :span="24">
<el-form-item prop="stockInType" label="出库类型">
<el-select v-model="formData.stockInType" clearable style="width: 100%">
<el-option v-for="dict in getIntDictOptions(DICT_TYPE.HELI_STORAGE_OUT_TYPE)" :key="dict.value"
:label="dict.label" :value="dict.value" />
<el-option
v-for="dict in getIntDictOptions(DICT_TYPE.HELI_STORAGE_OUT_TYPE)"
:key="dict.value"
:label="dict.label"
:value="dict.value"
/>
</el-select>
</el-form-item>
</el-col>
</el-row>
</el-col>
<el-col :span="8">
<el-row>
<el-col :span="24">
<el-form-item prop="industry" label="单据状态">
<el-select v-model="formData.status" placeholder="下拉选择" clearable class="!w-700px" disabled>
<el-option v-for="dict in getIntDictOptions(DICT_TYPE.HELI_STORAGE_STATUS)" :key="dict.value"
:label="dict.label" :value="dict.value" />
<el-select
v-model="formData.status"
placeholder="下拉选择"
clearable
class="!w-700px"
disabled
>
<el-option
v-for="dict in getIntDictOptions(DICT_TYPE.HELI_STORAGE_STATUS)"
:key="dict.value"
:label="dict.label"
:value="dict.value"
/>
</el-select>
</el-form-item>
</el-col>
@ -49,10 +69,8 @@
</el-form-item>
</el-col>
</el-row>
</el-col>
<el-col :span="8">
<el-row>
<el-col :span="24">
<el-form-item label="单据日期" prop="createTime">
@ -63,21 +81,35 @@
<el-row>
<el-col :span="24">
<el-form-item prop="whId" label="出库仓库" required>
<el-select v-model="formData.whId" placeholder="下拉选择" clearable class="!w-400px" @change="handleWh"
v-bind:disabled="btnWhClickable">
<el-option v-for="dict in warehouseList" :key="dict.id" :label="dict.whName" :value="dict.id" />
<el-select
v-model="formData.whId"
placeholder="下拉选择"
clearable
class="!w-400px"
@change="handleWh"
v-bind:disabled="btnWhClickable"
>
<el-option
v-for="dict in warehouseList"
:key="dict.id"
:label="dict.whName"
:value="dict.id"
/>
</el-select>
</el-form-item>
</el-col>
</el-row>
</el-col>
</el-row>
<el-row>
<el-col :span="24">
<el-form-item label="备注" prop="description">
<el-input type="textarea" v-model="formData.description" show-word-limit maxlength="200" />
<el-input
type="textarea"
v-model="formData.description"
show-word-limit
maxlength="200"
/>
</el-form-item>
</el-col>
</el-row>
@ -91,76 +123,135 @@
<el-col>
<el-card class="hl-incard">
<el-col>
<el-button class="hl-addbutton" type="primary" size="large" @click="onAddItem"></el-button>
<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-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 prop="cid" label="序号" :width="80" />
<el-table-column prop="matId" label="物料名称" :width="150">
<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="remoteMatCodeSearch"
remote-show-suffix remote clearable reserve-keyword filterable :loading="matSelectLoading"
@change="(val) => handleMatCode(scope, val)" class="!w-180px">
<el-option v-for="item in matList" :key="item.id" :label="item.name" :value="item.id" />
<el-form-item
:prop="`${scope.$index}.matId`"
:rules="subFormRules.matId"
class="mb-0px!"
>
<el-select
v-model="scope.row.matId"
placeholder="物料名称"
:remote-method="remoteMatCodeSearch"
remote-show-suffix
remote
clearable
reserve-keyword
filterable
:loading="matSelectLoading"
@change="(val) => handleMatCode(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="matCode" label="物料编码" />
<el-table-column prop="matType" label="物料类型">
<el-table-column prop="matCode" label="物料编码" min-width="120" align="center" />
<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" />
<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="规格/型号" />
<el-table-column prop="matSpec" label="规格/型号" min-width="120" align="center" />
<el-table-column prop="matUnit" label="系统单位">
<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" />
<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="rgId" width="140" label="出库库区" required>
<el-table-column prop="rgId" min-width="120" align="center">
<template #header> <span class="hl-table_header">*</span>出库库区 </template>
<template #default="scope">
<el-form-item :prop="`${scope.$index}.rgId`" :rules="subFormRules.rgId" class="mb-0px!">
<el-select v-model="scope.row.rgId" placeholder="" style="width: 100%" @change="handleRg(scope)"
disabled="">
<el-option v-for="dict in rgList" :key="dict.id" :label="dict.rgName" :value="dict.id" />
<el-form-item
:prop="`${scope.$index}.rgId`"
:rules="subFormRules.rgId"
class="mb-0px!"
>
<el-select
v-model="scope.row.rgId"
placeholder=""
style="width: 100%"
@change="handleRg(scope)"
disabled=""
>
<el-option
v-for="dict in rgList"
:key="dict.id"
:label="dict.rgName"
:value="dict.id"
/>
</el-select>
</el-form-item>
</template>
</el-table-column>
<el-table-column prop="pnId" width="140" label="出库库位" required>
<el-table-column prop="pnId" min-width="140" align="center">
<template #header> <span class="hl-table_header">*</span>出库库位 </template>
<template #default="scope">
<el-form-item :prop="`${scope.$index}.pnId`" :rules="subFormRules.pnId" class="mb-0px!">
<el-form-item
:prop="`${scope.$index}.pnId`"
:rules="subFormRules.pnId"
class="mb-0px!"
>
<el-select v-model="scope.row.pnId" placeholder="" style="width: 100%">
<el-option v-for="dict in scope.row.pnlist" :key="dict.id" :label="dict.pnName"
:value="dict.id" />
<el-option
v-for="dict in scope.row.pnlist"
:key="dict.id"
:label="dict.pnName"
:value="dict.id"
/>
</el-select>
</el-form-item>
</template>
</el-table-column>
<el-table-column prop="matRest" label="库存数量" />
<el-table-column prop="storageOkQty" width="120" label="出库数量" required>
<el-table-column prop="matRest" label="库存数量" min-width="120" align="center" />
<el-table-column prop="storageOkQty" min-width="120" align="center">
<template #header> <span class="hl-table_header">*</span>出库数量</template>
<template #default="scope">
<el-form-item :prop="`${scope.$index}.storageOkQty`" :rules="subFormRules.storageOkQty"
class="mb-0px!">
<el-form-item
:prop="`${scope.$index}.storageOkQty`"
:rules="subFormRules.storageOkQty"
class="mb-0px!"
>
<el-input v-model="scope.row.storageOkQty" />
</el-form-item>
</template>
</el-table-column>
<el-table-column prop="lotNo" width="120" label="批次号" />
<el-table-column prop="description" width="150" label="备注">
<el-table-column prop="lotNo" min-width="120" label="批次号" align="center" />
<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">
<el-table-column label="操作" align="center" width="120" fixed="right">
<template #default="scope">
<!-- <el-button v-if="!scope.row.editable" type="primary" size="small" link
@click="handleEdit(scope.$index)">
@ -171,8 +262,13 @@
</el-button>
<el-button link type="primary" @click="handlefuke(scope.$index, scope.row)">复制</el-button> -->
<el-button link type="danger" size="small" @click.prevent="handleDelete2(scope.$index)"
v-bind:disabled="isShowBtnOther">
<el-button
link
type="danger"
size="small"
@click.prevent="handleDelete2(scope.$index)"
v-bind:disabled="isShowBtnOther"
>
删除
</el-button>
</template>
@ -192,13 +288,24 @@
<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"
class="upload-file-uploader">
<el-button type="primary">
<Icon icon="ep:upload-filled" />上传
</el-button>
<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"
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">
@ -208,17 +315,33 @@
</template> -->
</el-table-column>
<el-table-column prop="createTime" align="center" label="上传日期" :formatter="dateFormatter" />
<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" v-bind:disabled="isShowBtnOther"
@click="handleDeleteAttachment(scope.$index, scope.row.businessFileType)">
<el-button
link
type="danger"
size="small"
v-bind:disabled="isShowBtnOther"
@click="handleDeleteAttachment(scope.$index, scope.row.businessFileType)"
>
删除
</el-button>
<el-button link type="primary" size="small" v-if="isShow"
@click="downloadAttachment(scope.row.name, scope.row.url)">
下载 </el-button>
<el-button
link
type="primary"
size="small"
v-if="isShow"
@click="downloadAttachment(scope.row.name, scope.row.url)"
>
下载
</el-button>
</template>
</el-table-column>
</el-table>
@ -272,41 +395,58 @@
</el-form>
<div class="text-center hl-footer">
<el-button @click="() => router.go(-1)" size="large"> </el-button>
<el-button @click="submitForm" v-if="isShowBtnGroup" type="success" :disabled="formLoading" size="large">
</el-button>
<el-button @click="handleStatus(2)" v-if="isShowBtnGroup" type="primary" :disabled="formLoading" size="large">
</el-button>
<el-button @click="handleStatus(3)" v-if="isShowBtnCancel" type="danger" :disabled="formLoading" size="large">
</el-button>
<el-button
@click="submitForm"
v-if="isShowBtnGroup"
type="success"
:disabled="formLoading"
size="large"
> </el-button
>
<el-button
@click="handleStatus(2)"
v-if="isShowBtnGroup"
type="primary"
:disabled="formLoading"
size="large"
> </el-button
>
<el-button
@click="handleStatus(3)"
v-if="isShowBtnCancel"
type="danger"
:disabled="formLoading"
size="large"
> </el-button
>
</div>
</el-card>
</template>
<script setup lang="ts">
import { ref } from 'vue'
import { useRoute } from "vue-router"
import { dateFormatter, formatDate } from "@/utils/formatTime"
import { useRoute } from 'vue-router'
import { dateFormatter, formatDate } from '@/utils/formatTime'
import type { UploadUserFile } from 'element-plus'
import { getIntDictOptions, DICT_TYPE } from '@/utils/dict'
import * as StorageApi from '@/api/heli/storage'
import * as StorageMatApi from '@/api/heli/storagemat'
import { getAccessToken, getTenantId } from "@/utils/auth"
import { getAccessToken, getTenantId } from '@/utils/auth'
import { useUserStore } from '@/store/modules/user'
import * as MaterialApi from '@/api/heli/material'
import * as WarehouseApi from '@/api/heli/warehouse'
import * as RgApi from '@/api/heli/rg'
import * as PnApi from '@/api/heli/pn'
import { deleteFile, downloadFile, getFilePage } from "@/api/infra/file"
import download from "@/utils/download"
import * as UserApi from "@/api/system/user";
import { deleteFile, downloadFile, getFilePage } from '@/api/infra/file'
import download from '@/utils/download'
import * as UserApi from '@/api/system/user'
const reload = inject('reload')
const { t } = useI18n() //
const message = useMessage() //
const { query } = useRoute()
const router = useRouter();
const router = useRouter()
const isShow = ref(false)
const dialogTitle = ref('') //
@ -348,11 +488,9 @@ const subFormRules = reactive({
matId: [{ required: true, message: '物料不能为空', trigger: 'blur' }],
rgId: [{ required: true, message: '库区不能为空', trigger: 'blur' }],
pnId: [{ required: true, message: '库位不能为空', trigger: 'blur' }],
storageOkQty: [{ required: true, message: '出库数量不能为空', trigger: 'blur' }],
storageOkQty: [{ required: true, message: '出库数量不能为空', trigger: 'blur' }]
})
const handleStatus = (async (num) => {
const handleStatus = async (num) => {
formData.value.status = num
const dataUpdate = formData.value as unknown as StorageApi.StorageVO
@ -367,37 +505,41 @@ const handleStatus = (async (num) => {
switch (num) {
case 1:
isShowBtnGroup.value = true;
isShowBtnCancel.value = false;
isShowBtnGroup.value = true
isShowBtnCancel.value = false
break
case 2:
isShowBtnGroup.value = false;
isShowBtnCancel.value = true;
isShowBtnGroup.value = false
isShowBtnCancel.value = true
break
case 3:
isShowBtnGroup.value = false;
isShowBtnCancel.value = false;
break;
isShowBtnGroup.value = false
isShowBtnCancel.value = false
break
default:
break
}
//
if (query.type === 'review') {
isShowBtnGroup.value = false;
isShowBtnCancel.value = false;
isShowBtnOther.value = true;
isShowBtnGroup.value = false
isShowBtnCancel.value = false
isShowBtnOther.value = true
}
reload()
})
}
const userList = ref<UserApi.UserVO[]>([]) //
// ==================== =======================================
const uploadUrl = ref(import.meta.env.VITE_UPLOAD_BATCH_URL)
const matUploadRef = ref();
const matUploadFiles = ref<UploadUserFile[]>([]);
const matUploadData = ref({ businessType: 'STORAGE', businessId: formData.value.id, businessFileType: 'MATERIAL' })
const matUploadRef = ref()
const matUploadFiles = ref<UploadUserFile[]>([])
const matUploadData = ref({
businessType: 'STORAGE',
businessId: formData.value.id,
businessFileType: 'MATERIAL'
})
const matUploadChange = (file, files) => {
matUploadFiles.value = files;
matUploadFiles.value = files
refreshAttachments(files, 'MATERIAL')
}
@ -406,28 +548,28 @@ const refreshAttachments = (files, type) => {
return value.id
})
for (let i = 0; i < files.length; i++) {
let file = files[i];
file.businessFileType = type;
file.createTime = new Date();
formData.value.attachments.push(file);
let file = files[i]
file.businessFileType = type
file.createTime = new Date()
formData.value.attachments.push(file)
}
//
formData.value.attachments.sort((v1, v2) => {
return (v1.createTime - v2.createTime) > 0
return v1.createTime - v2.createTime > 0
})
}
//
const handleDeleteAttachment = async (index, type) => {
const deletedAttachments = formData.value.attachments.splice(index, 1);
const deletedAttachments = formData.value.attachments.splice(index, 1)
for (let i = 0; i < deletedAttachments.length; i++) {
const attachment = deletedAttachments[i];
const attachment = deletedAttachments[i]
if (attachment.id) {
//
await deleteFile(attachment.id);
await deleteFile(attachment.id)
}
//
matUploadFiles.value = matUploadFiles.value.filter(file1 => {
return file1.name != attachment.name || file1.businessFileType != type;
matUploadFiles.value = matUploadFiles.value.filter((file1) => {
return file1.name != attachment.name || file1.businessFileType != type
})
}
}
@ -435,7 +577,7 @@ const handleDeleteAttachment = async (index, type) => {
const downloadAttachment = async (name, url) => {
if (url) {
const data = await downloadFile(url)
download.any(data, name);
download.any(data, name)
}
}
// ==================== =======================================
@ -459,8 +601,14 @@ const submitForm = async () => {
const matCurrentData = await StorageMatApi.getStorageMatList()
var hasRestNum = true
formData.value.matItemDOList.forEach((rest) => {
if (matCurrentData.find(mat => mat.matId == rest.matId && mat.pnId == rest.pnId && mat.matRest < Number(rest.storageOkQty))) {
if (
matCurrentData.find(
(mat) =>
mat.matId == rest.matId &&
mat.pnId == rest.pnId &&
mat.matRest < Number(rest.storageOkQty)
)
) {
hasRestNum = false
}
})
@ -469,24 +617,21 @@ const submitForm = async () => {
return
}
//
formLoading.value = true
try {
const data = formData.value as unknown as StorageApi.StorageVO
if (query.type === 'create') {
//
storageid.value = await StorageApi.createStorage(data)
commonResult = 'common.createSuccess'
} else {
storageid.value = data.id
await StorageApi.updateStorage(data)
commonResult = 'common.updateSuccess'
}
//
formData.value.matItemDOList.forEach(item => {
formData.value.matItemDOList.forEach((item) => {
item.stockId = storageid.value
item.whId = formData.value.whId
})
@ -501,9 +646,8 @@ const submitForm = async () => {
message.success(t(commonResult))
//
reload();
reload()
} finally {
formLoading.value = false
}
@ -534,7 +678,7 @@ const onAddItem = () => {
matCount = matCount + 1
formData.value.matItemDOList.push(newData)
} else {
message.alertWarning('选择出库仓库')
message.alertWarning('选择出库仓库')
}
}
@ -549,7 +693,7 @@ const warehouseList = ref([])
var rgList = ref([])
//
var pnList = ref([])
const handleWh = (async (wid) => {
const handleWh = async (wid) => {
//-------------------
const queryParamsRg = reactive({
pageNo: 1,
@ -562,14 +706,14 @@ const handleWh = (async (wid) => {
pnList.value = []
rgList.value = dataRg.list
formData.value.matItemDOList.forEach(item => {
formData.value.matItemDOList.forEach((item) => {
item.rgId = ''
item.pnId = ''
item.pnlist.value = []
})
//-------------------
})
const handleRg = (async (scope) => {
}
const handleRg = async (scope) => {
//-------------------
const queryParamsRPn = reactive({
pageNo: 1,
@ -581,10 +725,10 @@ const handleRg = (async (scope) => {
scope.row.pnid = ''
scope.row.pnlist = dataPn.list
//-------------------
})
}
const matList = ref<MaterialApi.MaterialVO[]>([]) //
const matSelectLoading = ref(false);
const matSelectLoading = ref(false)
const remoteMatCodeSearch = async (name) => {
matSelectLoading.value = true
//
@ -592,20 +736,20 @@ const remoteMatCodeSearch = async (name) => {
pageNo: 1,
pageSize: 10,
name: name,
status: "1"
status: '1'
}
const matLastRemoteData = await StorageMatApi.getStorageMatList()
const dataMat = await MaterialApi.getMaterialPage(matParams)
matList.value = []
matList.value = dataMat.list.filter((item) => matLastRemoteData.find((fish) => fish.matId === item.id) !== undefined)
matList.value = dataMat.list.filter(
(item) => matLastRemoteData.find((fish) => fish.matId === item.id) !== undefined
)
matSelectLoading.value = false
}
const handleMatCode = async (scope, matid) => {
if (matid && matLastData.value.find((item) => item.matId === matid)) {
const matVo = matLastData.value.find((item) => item.matId === matid)
scope.row.matId = matVo.matId
@ -653,7 +797,6 @@ const btnWhClickable = ref(false)
const matLastData = ref([])
/** 初始化 **/
onMounted(async () => {
btnWhClickable.value = query.type === 'update' ? true : false
matLastData.value = await StorageMatApi.getStorageMatList()
@ -662,17 +805,16 @@ onMounted(async () => {
let matParams = {
pageNo: 1,
pageSize: 99,
status: "1"
status: '1'
}
const dataMat = await MaterialApi.getMaterialPage(matParams)
matList.value = []
matList.value = dataMat.list
dialogTitle.value = t('action.' + query.type)
dialogTitle.value = query.type === 'review' ? '查看' : dialogTitle.value
isShow.value = query.type == "create" ? false : true
isShow.value = query.type == 'create' ? false : true
//-------------------
const data = await WarehouseApi.getWarehouseSimpList()
@ -684,25 +826,25 @@ onMounted(async () => {
switch (formData.value.status) {
case 1:
isShowBtnGroup.value = true;
isShowBtnCancel.value = false;
isShowBtnGroup.value = true
isShowBtnCancel.value = false
break
case 2:
isShowBtnGroup.value = false;
isShowBtnCancel.value = true;
isShowBtnGroup.value = false
isShowBtnCancel.value = true
break
case 3:
isShowBtnGroup.value = false;
isShowBtnCancel.value = false;
break;
isShowBtnGroup.value = false
isShowBtnCancel.value = false
break
default:
break
}
//
if (query.type === 'review') {
isShowBtnGroup.value = false;
isShowBtnCancel.value = false;
isShowBtnOther.value = true;
isShowBtnGroup.value = false
isShowBtnCancel.value = false
isShowBtnOther.value = true
}
//
@ -743,7 +885,7 @@ onMounted(async () => {
})
const matVos = await MaterialApi.getMaterialPage(queryParamsMat2)
formData.value.matItemDOList.forEach(item => {
formData.value.matItemDOList.forEach((item) => {
item.cid = matCount
item.matId = matVos.list.find((record) => record.id === item.matId)?.id
//item.matCode = matVos.list.find( (record) => record.id === item.matId)?.id
@ -752,18 +894,18 @@ onMounted(async () => {
item.matType = matVos.list.find((record) => record.id == item.matId)?.materialType
item.matUnit = matVos.list.find((record) => record.id == item.matId)?.unit
item.pnlist = pnList.value.filter((pn) => pn.rgId == item.rgId)
item.matRest = matLastData.value.find((rest) => rest.rgId == item.rgId && rest.pnId == item.pnId)?.matRest
item.matRest = matLastData.value.find(
(rest) => rest.rgId == item.rgId && rest.pnId == item.pnId
)?.matRest
item.matRest = item.matRest == undefined ? 0 : item.matRest
matCount = matCount + 1
// item = matLastData.value.find((rest) => rest.rgId === item.rgId && rest.pnId === item.pnId)
// item.pnlist = pnList.value.filter((pn) => pn.rgId === item.rgId)
// item.cid = matCount
// matCount = matCount + 1
})
//
let attParams = {
pageNo: 1,
@ -771,12 +913,11 @@ onMounted(async () => {
businessId: query.id,
businessType: 'STORAGE'
}
formData.value.attachments = (await getFilePage(attParams)).list;
formData.value.attachments = (await getFilePage(attParams)).list
}
//
userList.value = await UserApi.getSimpleUserList()
})
</script>
<style>

Loading…
Cancel
Save