入库单增加附件

master
zhangdi 2 weeks ago
parent c188ceffd9
commit e64909c987
  1. 373
      src/views/firstOrder/components/inDialog.vue

@ -1,64 +1,33 @@
<template>
<div>
<el-dialog
:close-on-click-modal="false"
:title="inDialogTiltle"
:visible.sync="inDialogVisible"
:append-to-body="true"
width="70%"
@close="handleCloseDetail"
fullscreen
class="dialog-container"
>
<el-dialog :close-on-click-modal="false" :title="inDialogTiltle" :visible.sync="inDialogVisible"
:append-to-body="true" width="70%" @close="handleCloseDetail" fullscreen class="dialog-container">
<!-- 基本信息 -->
<div class="dialog-content">
<el-form
:model="sizeForm"
ref="dynamicValidateForm"
label-width="100px"
class="demo-dynamic"
:rules="rules"
>
<el-form :model="sizeForm" ref="dynamicValidateForm" label-width="100px" class="demo-dynamic" :rules="rules">
<div class="form-title">基本信息</div>
<el-row>
<el-col
:span="12"
v-show="sizeForm.options == 1 && inDialogType != 'add'"
>
<el-form-item label="入库单号:" >
<el-col :span="12" v-show="sizeForm.options == 1 && inDialogType != 'add'">
<el-form-item label="入库单号:">
<el-input v-model="sizeForm.orderNo" disabled></el-input>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="入库时间:">
<el-date-picker
v-model="sizeForm.inDate"
format="yyyy-MM-dd"
value-format="yyyy-MM-dd"
type="date"
placeholder="选择日期"
style="width: 100%"
disabled
>
<el-date-picker v-model="sizeForm.inDate" format="yyyy-MM-dd" value-format="yyyy-MM-dd" type="date"
placeholder="选择日期" style="width: 100%" disabled>
</el-date-picker>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="事由:" required>
<el-input
v-model="sizeForm.reason"
:disabled="inDialogType == 'details'"
></el-input>
<el-input v-model="sizeForm.reason" :disabled="inDialogType == 'details'"></el-input>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="物资类型:" required>
<el-select
v-model="sizeForm.materialType"
placeholder="请选择"
style="width: 100%"
:disabled="inDialogType == 'details'"
>
<el-select v-model="sizeForm.materialType" placeholder="请选择" style="width: 100%"
:disabled="inDialogType == 'details'">
<el-option label="办公物资" value="1"></el-option>
<el-option label="其他物资" value="2"></el-option>
</el-select>
@ -66,12 +35,8 @@
</el-col>
<el-col :span="12">
<el-form-item prop="source" label="来源:" required>
<el-select
v-model="sizeForm.source"
placeholder="请选择"
style="width: 100%"
:disabled="inDialogType == 'details'"
>
<el-select v-model="sizeForm.source" placeholder="请选择" style="width: 100%"
:disabled="inDialogType == 'details'">
<el-option label="采购申请" value="cg"></el-option>
<el-option label="其他来源" value="qt"></el-option>
</el-select>
@ -79,11 +44,7 @@
</el-col>
<el-col :span="12">
<el-form-item label="选项:" required>
<el-radio-group
v-model="sizeForm.option"
@change="radioChange()"
:disabled="inDialogType == 'details'"
>
<el-radio-group v-model="sizeForm.option" @change="radioChange()" :disabled="inDialogType == 'details'">
<el-radio :label="1">批量选择</el-radio>
<el-radio :label="2">单项选择</el-radio>
</el-radio-group>
@ -94,28 +55,24 @@
<el-input v-model="sizeForm.quarterName" disabled></el-input>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item prop="source" label="附件:">
<el-upload class="upload-demo" action="/smartparkAPP/ld-person-form/upload" :on-preview="handlePreview"
:on-remove="handleRemove" :before-remove="beforeRemove" multiple :limit="6" :on-exceed="handleExceed"
:file-list="fileList" :on-success="handleUploadSuccess" accept=".jpg,.jpeg,.png,.pdf"
:before-upload="beforeAvatarUpload" :disabled="inDialogType == 'details'">
<el-button size="small" type="primary">点击上传</el-button>
<div slot="tip" class="el-upload__tip">只能上传 jpg/png/pdf 文件且单个文件不超过 6MB</div>
</el-upload>
</el-form-item>
</el-col>
</el-row>
<div class="form-title">{{ inDate }}</div>
<el-button
type="primary"
size="mini"
style="margin-bottom: 18px"
@click="inTableAdd()"
v-if="!allDisabled && sizeForm.option == 2"
>新增</el-button
>
<el-button type="primary" size="mini" style="margin-bottom: 18px" @click="inTableAdd()"
v-if="!allDisabled && sizeForm.option == 2">新增</el-button>
<!-- 批量选择 -->
<el-table
:data="sizeForm.inTableData"
border
style="width: 100%"
v-show="sizeForm.option == 1"
>
<el-table-column
prop="inboundDetailCode"
label="入库明细单号"
v-if="inDialogType == 'details'"
>
<el-table :data="sizeForm.inTableData" border style="width: 100%" v-show="sizeForm.option == 1">
<el-table-column prop="inboundDetailCode" label="入库明细单号" v-if="inDialogType == 'details'">
</el-table-column>
<el-table-column prop="materialCode" label="物资编码">
</el-table-column>
@ -124,31 +81,17 @@
<el-table-column prop="model" label="规格"> </el-table-column>
<el-table-column prop="unit" label="单位"> </el-table-column>
<el-table-column
prop="requiredQuantity"
label="计划采购数量"
v-if="sizeForm.option == 1"
>
<el-table-column prop="requiredQuantity" label="计划采购数量" v-if="sizeForm.option == 1">
<template slot-scope="scope">
{{ scope.row.requiredQuantity || 0 }}
</template>
</el-table-column>
<el-table-column
prop="yetInboundQuantity"
label="已入库数量"
v-if="sizeForm.option == 1"
>
<el-table-column prop="yetInboundQuantity" label="已入库数量" v-if="sizeForm.option == 1">
</el-table-column>
<el-table-column prop="theInboundQuantity" label="本次入库数量">
<template slot-scope="scope">
<el-input-number
size="mini"
v-model="scope.row.theInboundQuantity"
:min="0"
style="width: 100%"
@change="syncInboundQuantity(scope.row)"
v-if="inDialogType != 'details'"
></el-input-number>
<el-input-number size="mini" v-model="scope.row.theInboundQuantity" :min="0" style="width: 100%"
@change="syncInboundQuantity(scope.row)" v-if="inDialogType != 'details'"></el-input-number>
<span v-else>{{
scope.row.theInboundQuantity === undefined
? 0
@ -158,14 +101,9 @@
</el-table-column>
<el-table-column prop="type" label="类别">
<template slot-scope="scope">
<el-select
v-model="scope.row.type"
placeholder="请选择"
style="width: 100%"
:disabled="inDialogType == 'details'"
@change="handleTypeChange(scope.row)"
v-if="inDialogType != 'details'"
>
<el-select v-model="scope.row.type" placeholder="请选择" style="width: 100%"
:disabled="inDialogType == 'details'" @change="handleTypeChange(scope.row)"
v-if="inDialogType != 'details'">
<el-option label="耐用品" value="NY"></el-option>
<el-option label="易耗品" value="YH"></el-option>
</el-select>
@ -176,62 +114,31 @@
</el-table-column>
<el-table-column prop="unitPrice" label="单价">
<template slot-scope="scope">
<el-input-number
size="mini"
v-model="scope.row.unitPrice"
:min="0"
style="width: 100%"
<el-input-number size="mini" v-model="scope.row.unitPrice" :min="0" style="width: 100%"
@change="syncUnitPrice(scope.row)"
v-if="inDialogType != 'details' && scope.row.type !== 'YH'"
></el-input-number>
v-if="inDialogType != 'details' && scope.row.type !== 'YH'"></el-input-number>
<span v-else-if="scope.row.type === 'YH'">-</span>
<span v-else>{{ scope.row.unitPrice || 0 }}</span>
</template>
</el-table-column>
<el-table-column prop="remark" label="备注">
<template slot-scope="scope">
<el-input
v-model="scope.row.remark"
placeholder="请输入备注"
v-if="inDialogType != 'details'"
></el-input>
<el-input v-model="scope.row.remark" placeholder="请输入备注" v-if="inDialogType != 'details'"></el-input>
<span v-else>{{ scope.row.remark }}</span>
</template>
</el-table-column>
</el-table>
<!-- 单项选择 -->
<el-table
:data="sizeForm.singleData"
border
style="width: 100%"
v-show="sizeForm.option == 2"
align="center"
>
<el-table-column
prop="inboundDetailCode"
label="入库明细单号"
v-if="inDialogType == 'details'"
>
<el-table :data="sizeForm.singleData" border style="width: 100%" v-show="sizeForm.option == 2" align="center">
<el-table-column prop="inboundDetailCode" label="入库明细单号" v-if="inDialogType == 'details'">
</el-table-column>
<el-table-column
prop="materialCode"
label="物资编码"
></el-table-column>
<el-table-column prop="materialCode" label="物资编码"></el-table-column>
<el-table-column prop="materialName" label="物资名称">
<template slot-scope="scope">
<el-select
v-model="scope.row.materialId"
placeholder="请选择物资名称"
style="width: 100%"
@change="handleMaterialChange(scope.row)"
v-if="inDialogType != 'details'"
>
<el-option
v-for="item in materials"
:key="item.materialId"
:label="item.materialName"
:value="item.materialId"
>
<el-select v-model="scope.row.materialId" placeholder="请选择物资名称" style="width: 100%"
@change="handleMaterialChange(scope.row)" v-if="inDialogType != 'details'">
<el-option v-for="item in materials" :key="item.materialId" :label="item.materialName"
:value="item.materialId">
</el-option>
</el-select>
<span v-else> {{ scope.row.materialName }}</span>
@ -240,46 +147,27 @@
<el-table-column prop="model" label="物资规格"></el-table-column>
<el-table-column prop="unit" label="单位"></el-table-column>
<el-table-column
prop="requiredQuantity"
label="计划采购数量"
v-if="sizeForm.option == 1"
>
<el-table-column prop="requiredQuantity" label="计划采购数量" v-if="sizeForm.option == 1">
<template slot-scope="scope">
{{ scope.row.requiredQuantity || 0 }}
</template>
</el-table-column>
<el-table-column
prop="inboundQuantity"
label="已入库数量"
v-if="sizeForm.option == 1"
>
<el-table-column prop="inboundQuantity" label="已入库数量" v-if="sizeForm.option == 1">
<template slot-scope="scope">
{{ scope.row.inboundQuantity || 0 }}
</template>
</el-table-column>
<el-table-column prop="theInboundQuantity" label="本次入库数量">
<template slot-scope="scope">
<el-input-number
size="mini"
v-model="scope.row.theInboundQuantity"
:min="0"
style="width: 100%"
@change="syncInboundQuantity(scope.row)"
v-if="inDialogType != 'details'"
></el-input-number>
<el-input-number size="mini" v-model="scope.row.theInboundQuantity" :min="0" style="width: 100%"
@change="syncInboundQuantity(scope.row)" v-if="inDialogType != 'details'"></el-input-number>
<span v-else>{{ scope.row.theInboundQuantity || 0 }}</span>
</template>
</el-table-column>
<el-table-column prop="type" label="类别 ">
<template slot-scope="scope">
<el-select
v-model="scope.row.type"
placeholder="请选择"
style="width: 100%"
@change="handleTypeChange(scope.row)"
v-if="inDialogType !== 'details'"
>
<el-select v-model="scope.row.type" placeholder="请选择" style="width: 100%"
@change="handleTypeChange(scope.row)" v-if="inDialogType !== 'details'">
<el-option label="耐用品" value="NY"></el-option>
<el-option label="易耗品" value="YH"></el-option>
</el-select>
@ -290,14 +178,9 @@
</el-table-column>
<el-table-column prop="unitPrice" label="单价">
<template slot-scope="scope">
<el-input-number
size="mini"
v-model="scope.row.unitPrice"
:min="0"
style="width: 100%"
<el-input-number size="mini" v-model="scope.row.unitPrice" :min="0" style="width: 100%"
@change="syncUnitPrice(scope.row)"
v-if="inDialogType != 'details' && scope.row.type !== 'YH'"
></el-input-number>
v-if="inDialogType != 'details' && scope.row.type !== 'YH'"></el-input-number>
<span v-else-if="scope.row.type === 'YH'">-</span>
<span v-else>{{ scope.row.unitPrice || 0 }}</span>
</template>
@ -307,18 +190,9 @@
<div class="form-title" v-if="inDialogType !== 'details'">
入库账目表格
</div>
<el-table
:data="statisticsList"
border
style="width: 100%"
v-if="inDialogType !== 'details'"
>
<el-table :data="statisticsList" border style="width: 100%" v-if="inDialogType !== 'details'">
<el-table-column prop="date" label="当前库存">
<el-table-column
prop="inboundDetailCode"
label="入库明细单号"
v-if="inDialogType == 'details'"
>
<el-table-column prop="inboundDetailCode" label="入库明细单号" v-if="inDialogType == 'details'">
</el-table-column>
<el-table-column prop="materialCode" label="物资编码">
</el-table-column>
@ -332,8 +206,8 @@
scope.row.type === "NY"
? "耐用品"
: scope.row.type === "YH"
? "易耗品"
: ""
? "易耗品"
: ""
}}
</template>
</el-table-column>
@ -368,8 +242,7 @@
<el-table-column prop="unitPrice" label="单价">
<template slot-scope="scope">
<span v-if="scope.row.type === 'YH'">-</span>
<span v-else>{{ scope.row.unitPrice || 0 }}</span> </template
>s
<span v-else>{{ scope.row.unitPrice || 0 }}</span> </template>s
</el-table-column>
</el-table-column>
<el-table-column prop="date" label="入库信息">
@ -393,37 +266,16 @@
</div>
<span slot="footer" class="dialog-footer" v-if="!allDisabled">
<el-button @click="handleCloseDetail()"> </el-button>
<el-button type="primary" @click="submit(1)" :loading="isSubmitting"
>暂存</el-button
>
<el-button type="primary" @click="submit(2)" :loading="isSubmitting"
>提交</el-button
>
<el-button type="primary" @click="submit(1)" :loading="isSubmitting">暂存</el-button>
<el-button type="primary" @click="submit(2)" :loading="isSubmitting">提交</el-button>
</span>
</el-dialog>
<!-- 批量出库 选择 -->
<el-dialog
:close-on-click-modal="false"
title="选择数据来源"
:visible.sync="inBatchDialogVisible"
:append-to-body="true"
width="40%"
@close="handleBatchClose"
@open="getBatchOptions"
>
<el-select
v-model="batchType"
placeholder="请选择数据来源"
style="width: 100%"
:clearable="true"
>
<el-option
v-for="item in batchOptions"
:key="item.ids"
:label="item.quarterName"
:value="item.ids"
>
<el-dialog :close-on-click-modal="false" title="选择数据来源" :visible.sync="inBatchDialogVisible" :append-to-body="true"
width="40%" @close="handleBatchClose" @open="getBatchOptions">
<el-select v-model="batchType" placeholder="请选择数据来源" style="width: 100%" :clearable="true">
<el-option v-for="item in batchOptions" :key="item.ids" :label="item.quarterName" :value="item.ids">
</el-option>
</el-select>
<span slot="footer" class="dialog-footer">
@ -470,6 +322,7 @@ export default {
},
data() {
return {
fileList: [],
isSubmitting: false,
inDialogVisible: false,
sizeForm: {
@ -522,6 +375,55 @@ export default {
this.sizeForm.userInfoVO = this.userInfo;
},
methods: {
handleRemove(file, fileList) {
console.log(file, fileList);
this.fileList = fileList;
},
handlePreview(file) {
console.log(file);
const fileUrl = file.url || (file.response && file.response.result && file.response.result.fileUrl);
if (!fileUrl) return;
// Token URL Token
// const token = this.$store.getters.access_token;
// const previewUrl = `${fileUrl}?token=${token}`;
// OSS
window.open(fileUrl, '_blank');
},
handleExceed(files, fileList) {
this.$message.warning(`当前限制选择 6 个文件,本次选择了 ${files.length} 个文件,共选择了 ${files.length + fileList.length} 个文件`);
},
beforeRemove(file, fileList) {
return this.$confirm(`确定移除 ${file.name}`);
},
handleUploadSuccess(response, file, fileList) {
this.fileList = fileList;
},
beforeAvatarUpload(file) {
// 1.
const isJPG = file.type === 'image/jpeg' || file.type === 'image/png';
const isPDF = file.type === 'application/pdf';
// type
const fileName = file.name.toLowerCase();
const isExtValid = fileName.endsWith('.jpg') || fileName.endsWith('.jpeg') || fileName.endsWith('.png') || fileName.endsWith('.pdf');
if (!isJPG && !isPDF && !isExtValid) {
this.$message.error('上传文件只能是 JPG/PNG/PDF 格式!');
return false;
}
// 2. (6MB = 6 * 1024 * 1024 bytes)
const isLt6M = file.size / 1024 / 1024 < 6;
if (!isLt6M) {
this.$message.error('上传文件大小不能超过 6MB!');
return false;
}
return true;
},
//
getStatistics() {
getStatistics(this.sizeForm.inTableData).then((res) => {
@ -562,7 +464,7 @@ export default {
(item) =>
item.materialId === stat.materialId && item.type === stat.type
);
if (stat.type == "YH") {
if (stat.type == "YH") {
stat.theInboundQuantity = detail.theInboundQuantity; //
stat.totalQuantity = stat.num + detail.theInboundQuantity;
stat.unitPrice = detail.unitPrice;
@ -632,6 +534,20 @@ export default {
const res = await editList(this.id);
const { ldOnePutStorage, ldOnePutStorageDetailList = [] } =
res.data.result || {};
if(ldOnePutStorage.onePutStorageFilesList&&ldOnePutStorage.onePutStorageFilesList.length>0){
this.fileList = ldOnePutStorage.onePutStorageFilesList.map(item => {
return {
name: item.fileName || '未知文件', //
url: item.picture, //
uid: item.mediaId || Date.now(), //
// 便使
...item
};
});
} else {
this.fileList = [];
}
if (!ldOnePutStorage) {
this.$message.error("回显数据异常");
return;
@ -765,7 +681,7 @@ export default {
} else {
this.sizeForm.singleData.push({ ...row, ...materialData });
}
this.getStatisticsSingle();
this.getStatisticsSingle();
} else {
this.$message.error(res.data.message || "获取物资信息失败");
}
@ -815,7 +731,7 @@ export default {
return;
}
if (row.type === "NY") {
if ((row.theInboundQuantity > 0)&&(row.unitPrice === undefined || row.unitPrice <= 0)) {
if ((row.theInboundQuantity > 0) && (row.unitPrice === undefined || row.unitPrice <= 0)) {
this.$message.error("单价不能为空");
return;
}
@ -829,14 +745,14 @@ export default {
return;
}
if (
row.theInboundQuantity>0&&
( row.theInboundQuantity + row.yetInboundQuantity >
row.theInboundQuantity > 0 &&
(row.theInboundQuantity + row.yetInboundQuantity >
row.requiredQuantity &&
!row.remark)
!row.remark)
) {
this.$message.warning(
row.materialName +
"本次入库数量不能大于采购单计划数量,请填写备注原因"
"本次入库数量不能大于采购单计划数量,请填写备注原因"
);
return;
}
@ -862,7 +778,7 @@ export default {
return;
}
if (row.type === "NY") {
if ((row.theInboundQuantity > 0)&&(row.unitPrice === undefined || row.unitPrice <= 0)) {
if ((row.theInboundQuantity > 0) && (row.unitPrice === undefined || row.unitPrice <= 0)) {
this.$message.error("单价不能为空");
return;
}
@ -879,17 +795,25 @@ export default {
this.isSubmitting = true;
this.sizeForm.status = index;
if (this.sizeForm.option == 1) {
// this.sizeForm.singleData = [];
this.sizeForm.ldOnePutStorageDetailVOList = this.sizeForm.inTableData;
this.sizeForm.options = this.sizeForm.option;
this.sizeForm.purchaseEndInfo = this.sizeForm.quarterName;
// this.sizeForm.option = "";
} else if (this.sizeForm.option == 2) {
this.sizeForm.inTableData = [];
this.sizeForm.ldOnePutStorageDetailVOList = this.sizeForm.singleData;
this.sizeForm.options = this.sizeForm.option;
// this.sizeForm.option = "";
}
if (this.fileList.length > 0) {
this.sizeForm.onePutStorageFilesList = []
this.fileList.forEach(item => {
this.sizeForm.onePutStorageFilesList.push({
fileName: item.response.result.fileName,
fileUrl: item.response.result.fileUrl,
mediaId: item.response.result.mediaId,
})
})
}
console.log(this.sizeForm, 99);
try {
const res = await submitData(this.sizeForm);
if (res.data.success) {
@ -958,9 +882,11 @@ export default {
::v-deep .el-table th {
text-align: center !important;
}
.form-title {
margin: 20px 0;
}
::v-deep.el-dialog__footer {
position: fixed !important;
bottom: 0 !important;
@ -972,6 +898,7 @@ export default {
overflow-y: auto;
padding-right: 10px;
}
::v-deep.el-table th.el-table__cell {
background: #f5f7fa;
font-weight: 500;

Loading…
Cancel
Save