出入库 附件信息 调整

出入库 附件信息 调整
pull/1/head
siontion 9 months ago
parent 4f467c7de2
commit 901a1afdcd

@ -12,14 +12,14 @@
<el-col :span="8">
<el-row>
<el-col :span="24">
<el-form-item prop="name" label="入库单号" >
<el-form-item prop="name" label="入库单号">
<el-input v-model="formData.stockNo" disabled />
</el-form-item>
</el-col>
</el-row>
<el-row>
<el-col :span="24">
<el-form-item prop="stockInType" label="入库类型" >
<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" />
@ -32,7 +32,7 @@
<el-col :span="8">
<el-row>
<el-col :span="24">
<el-form-item prop="name" label="单号日期" >
<el-form-item prop="name" label="单号日期">
<el-input v-model="formData.name" disabled />
</el-form-item>
</el-col>
@ -95,13 +95,13 @@
<el-table-column prop="matCode" label="物料编码" required>
<template #default="scope">
<el-select v-model="scope.row.matCode" placeholder="物料编码" :remote-method="remoteMatCodeSearch"
remote-show-suffix remote clearable reserve-keyword filterable :loading="matSelectLoading" @change="(val) => handleMatCode(scope,val)"
class="!w-180px">
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>
</template>
</el-table-column>
<el-table-column prop="matName" label="物料名称" >
<el-table-column prop="matName" label="物料名称">
<!-- <template #default="scope">
<el-input v-model="scope.row.matName"
:disabled="!scope.row.editable" />
@ -116,14 +116,16 @@
</el-table-column>
<el-table-column prop="matType" label="物料类型">
<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="系统单位">
<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>
@ -142,17 +144,17 @@
</el-table-column>
<el-table-column prop="storageOkQty" width="120" label="入库数量" required>
<template #default="scope">
<el-input v-model="scope.row.storageOkQty" />
<el-input v-model="scope.row.storageOkQty" />
</template>
</el-table-column>
<el-table-column prop="lotNo" width="120" label="批次号">
<template #default="scope">
<el-input v-model="scope.row.lotNo" />
<el-input v-model="scope.row.lotNo" />
</template>
</el-table-column>
<el-table-column prop="description" width="150" label="备注">
<template #default="scope">
<el-input v-model="scope.row.description" />
<el-input v-model="scope.row.description" />
</template>
</el-table-column>
<el-table-column label="操作" align="center" width="240">
@ -185,14 +187,17 @@
<el-col>
<el-card class="hl-incard">
<el-col>
<el-upload v-model:file-list="fileList" :show-file-list="false" class="upload-demo"
action="https://run.mocky.io/v3/9d059bf9-4660-45f2-925d-ce80ad6c4d15" multiple
:on-preview="handlePreview" :on-remove="handleRemove" :before-remove="beforeRemove" :limit="3"
:on-exceed="handleExceed" @before-upload="handleBeforeUpload">
<el-button type="primary" size="large" class="hl-addbutton">上传</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="{ 'businessType': 'STORAGE', 'businessId': formData.id, 'businessFileType': 'MATERIAL' }"
: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="fileList" class="hl-table">
<el-table :data="matUploadFiles" class="hl-table">
<el-table-column prop="name" label="文件名称" align="center">
<template #default="scope">
<!-- <div></div> -->
@ -200,14 +205,17 @@
</template>
</el-table-column>
<el-table-column prop="uploadTimestamp" align="center" label="上传日期" />
<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="handleDelete(scope.$index)">
<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>
<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>
@ -268,19 +276,21 @@
</template>
<script setup lang="ts">
import { ref } from 'vue'
import { ElMessage, ElMessageBox } from 'element-plus'
import type { UploadProps, UploadUserFile } from 'element-plus'
import { dateFormatter } 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 * 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} from "@/api/infra/file";
import download from "@/utils/download";
import { deleteFile, downloadFile } from "@/api/infra/file"
import download from "@/utils/download"
const { t } = useI18n() //
const message = useMessage() //
@ -309,17 +319,66 @@ const formData = ref({
outboundTime: undefined,
cancel: undefined,
cancelTime: undefined,
productBomItemDOList: []
productBomItemDOList: [],
attachments: []
})
const formRules = reactive({
// name: [{ required: true, message: '', trigger: 'blur' }],
status: [{ required: true, message: '启用状态不能为空', trigger: 'blur' }],
stockInType :[{ required: true, message: '入库类型不能为空', trigger: 'blur' }],
whId :[{ required: true, message: '入库仓库不能为空', trigger: 'blur' }]
stockInType: [{ required: true, message: '入库类型不能为空', trigger: 'blur' }],
whId: [{ required: true, message: '入库仓库不能为空', trigger: 'blur' }]
})
const formRef = ref() // Ref
// ==================== =======================================
const uploadUrl = ref(import.meta.env.VITE_UPLOAD_BATCH_URL)
const matUploadRef = ref();
const matUploadFiles = ref<UploadUserFile[]>([]);
const matUploadChange = (file, files) => {
matUploadFiles.value = files;
refreshAttachments(files, 'MATERIAL')
}
const refreshAttachments = (files, type) => {
formData.value.attachments = formData.value.attachments.filter((value, index, array) => {
return value.businessFileType != type;
});
for (let i = 0; i < files.length; i++) {
let file = files[i];
file.businessFileType = type;
file.createTime = new Date();
formData.value.attachments.push(file);
}
//
formData.value.attachments.sort((v1, v2) => {
return v1.businessFileType == v2.businessFileType ? 0 : 1;
})
}
//
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;
})
protocolUploadFiles.value = protocolUploadFiles.value.filter(file2 => {
return file2.name != attachment.name || file2.businessFileType != type;
})
}
}
//
const downloadAttachment = async (name, url) => {
const data = await downloadFile(url)
download.any(data, name);
}
// ==================== =======================================
/** 打开弹窗 */
const open = async (type: string, id?: number) => {
dialogVisible.value = true
@ -351,9 +410,9 @@ const submitForm = async () => {
if (router.query.type === 'create') {
storageid.value = await StorageApi.createStorage(data)
formData.value.productBomItemDOList.forEach( item=>{
item.stockId = storageid.value
item.whId = formData.value.whId
formData.value.productBomItemDOList.forEach(item => {
item.stockId = storageid.value
item.whId = formData.value.whId
})
const dataMats = formData.value.productBomItemDOList as unknown as StorageMatApi.StorageMatVO[]
@ -373,41 +432,31 @@ const submitForm = async () => {
}
}
const goback = () => {
resetForm()
}
/** 重置表单 */
const resetForm = () => {
formData.value = {
id: undefined,
name: undefined,
status: 1,
productBomItemDOList: []
}
formRef.value?.resetFields()
}
var matCount = 1
const onAddItem = () => {
const newData = {
//
cid : matCount,
stockId : 0,
cid: matCount,
stockId: 0,
matId: '',
matName: '',
matCode: '',
matType : '',
matType: '',
matSpec: '',
matUnit: '',
whId: '',
rgId: '',
pnId: '',
pnlist : ref([]),
pnlist: ref([]),
storageOkQty: '',
lotNo: '',
description: '',
productBomItemValueDOList: []
}
matCount = matCount+ 1
matCount = matCount + 1
formData.value.productBomItemDOList.push(newData)
}
@ -419,121 +468,36 @@ const handlefuke = (index, item) => {
//
const newData: any = {
...data,
cid : matCount,
stockId : item.stockId,
cid: matCount,
stockId: item.stockId,
matId: item.matId,
matName: item.matName,
matCode: item.matCode,
matType : item.matType,
matType: item.matType,
matSpec: item.matSpec,
matUnit: item.matUnit,
whId: item.whId,
rgId: item.rgId,
pnId: item.pnId,
pnlist : item.pnlist,
pnlist: item.pnlist,
storageOkQty: item.storageOkQty,
lotNo: item.lotNo,
description: item.description,
productBomItemValueDOList: []
}
matCount = matCount+ 1
matCount = matCount + 1
//
formData.value.productBomItemDOList.splice(index + 1, 0, newData)
}
// / input
const handleEdit = (index) => {
formData.value.productBomItemDOList[index].editable = true
}
const handleSave = (index) => {
formData.value.productBomItemDOList[index].editable = false
}
const handleCellClick = (row, column, event) => {
if (row.editable) {
column.el.querySelector('input').focus()
}
}
const handleCellBlur = (row, column, event) => {
if (row.editable) {
column.el.querySelector('input').blur()
}
}
//
const handleDelete2 = (index: number) => {
formData.value.productBomItemDOList.splice(index, 1)
}
//
const fileList = ref([
{
name: 'element-plus-logo.svg',
url: 'http://127.0.0.1:8080/admin-api/infra/file/5/get/d229467d4ad143582725cc39d16dd04c660034b71e3ddcfe930901639bbccee5.png',
uploadTimestamp: '2024-1-12 1606'
},
{
name: 'element-plus-logo2.svg',
url: 'https://element-plus.org/images/element-plus-logo.svg',
uploadTimestamp: '2024-1-12 1606'
}
])
const handleRemove: UploadProps['onRemove'] = (file, uploadFiles) => {
console.log(file, uploadFiles, '11')
}
const handlePreview: UploadProps['onPreview'] = (uploadFile) => {
console.log(uploadFile, '222')
}
const handleExceed: UploadProps['onExceed'] = (files, uploadFiles) => {
ElMessage.warning(
`The limit is 3, you selected ${files.length} files this time, add up to ${files.length + uploadFiles.length
} totally`
)
console.log('333')
}
//
const downloadAttachment = async (name, url) => {
const data = await downloadFile(url)
download.any(data, name);
}
let uploadTimestamp: any = null
const handleBeforeUpload = (file: File) => {
uploadTimestamp = new Date().toISOString() //
// false
// return false;
// filelist
const newFile: any = {
name: '',
url: '', // URL
uploadTimestamp: uploadTimestamp!,
};
fileList.value.push(newFile);
}
const beforeRemove: UploadProps['beforeRemove'] = (uploadFile, uploadFiles) => {
console.log('444', uploadFile, uploadFiles)
return ElMessageBox.confirm(`Cancel the transfer of ${uploadFile.name} ?`).then(
() => true,
() => false
)
}
//
const handleDelete = (index: number) => {
fileList.value.splice(index, 1)
}
//
const warehouseList = ref([])
//
@ -553,7 +517,7 @@ const handleWh = (async (wid) => {
pnList.value = []
rgList.value = dataRg.list
formData.value.productBomItemDOList.forEach( item =>{
formData.value.productBomItemDOList.forEach(item => {
item.rgId = ''
item.pnId = ''
item.pnlist.value = []
@ -570,54 +534,39 @@ const handleRg = (async (scope) => {
})
const dataPn = await PnApi.getPnPage(queryParamsRPn)
scope.row.pnid = ''
scope.row.pnlist = dataPn.list
scope.row.pnlist = dataPn.list
//-------------------
})
const matList = ref<MaterialApi.MaterialVO[]>([]) //
const matList = ref<MaterialApi.MaterialVO[]>([]) //
const matSelectLoading = ref(false);
const remoteMatSearch = async (query) => {
matSelectLoading.value= true
//
let matParams = {
pageNo: 1,
pageSize: 10,
name : query,
status: "1"
}
const dataMat = await MaterialApi.getMaterialPage(matParams)
matList.value = []
matList.value = dataMat.list
matSelectLoading.value= false
}
const remoteMatCodeSearch = async (query) => {
matSelectLoading.value= true
matSelectLoading.value = true
//
let matParams = {
pageNo: 1,
pageSize: 10,
code : query,
code: query,
status: "1"
}
const dataMat = await MaterialApi.getMaterialPage(matParams)
matList.value = []
matList.value = dataMat.list
matSelectLoading.value= false
matSelectLoading.value = false
}
const handleMatCode = async (scope,matid) =>{
const handleMatCode = async (scope, matid) => {
if(matid){
if (matid) {
const matVo = await MaterialApi.getMaterial(scope.row.matCode)
scope.row.matId = matVo.id
scope.row.matName = matVo.name
scope.row.matSpec = matVo.spec
scope.row.matType = matVo.materialType
scope.row.matUnit = matVo.unit
}else{
} else {
scope.row.matId = ''
scope.row.matCode = ''
scope.row.matName = ''

Loading…
Cancel
Save