二级出库修改

master
zhangdi 2 weeks ago
parent e64909c987
commit 85377b1d3d
  1. 400
      src/views/secondOrder/components/outDialog.vue

@ -1,56 +1,30 @@
<template> <template>
<div> <div>
<el-dialog <el-dialog :close-on-click-modal="false" :title="outDialogTiltle" :visible.sync="outDialogVisible"
:close-on-click-modal="false" :append-to-body="true" @close="handleCloseDetail" fullscreen>
:title="outDialogTiltle"
:visible.sync="outDialogVisible"
:append-to-body="true"
@close="handleCloseDetail"
fullscreen
>
<div class="dialog-content"> <div class="dialog-content">
<!-- 基本信息 --> <!-- 基本信息 -->
<el-form <el-form :model="sizeForm" ref="dynamicValidateForm" label-width="100px" class="demo-dynamic"
:model="sizeForm" :rules="dynamicRules">
ref="dynamicValidateForm"
label-width="100px"
class="demo-dynamic"
:rules="dynamicRules"
>
<div class="form-title">基本信息</div> <div class="form-title">基本信息</div>
<el-row> <el-row>
<el-col :span="12"> <el-col :span="12">
<el-form-item label="出库申请时间"> <el-form-item label="出库申请时间">
<el-date-picker <el-date-picker v-model="sizeForm.ldTwoOutStorage.outDate" type="date" placeholder="选择日期"
v-model="sizeForm.ldTwoOutStorage.outDate" style="width: 100%" disabled>
type="date"
placeholder="选择日期"
style="width: 100%"
disabled
>
</el-date-picker> </el-date-picker>
</el-form-item> </el-form-item>
</el-col> </el-col>
<el-col :span="12"> <el-col :span="12">
<el-form-item label="事由" prop="ldTwoOutStorage.reason"> <el-form-item label="事由" prop="ldTwoOutStorage.reason">
<el-input <el-input v-model="sizeForm.ldTwoOutStorage.reason" :disabled="outDialogType != 'add'"
v-model="sizeForm.ldTwoOutStorage.reason" placeholder="请输入"></el-input>
:disabled="outDialogType != 'add'"
placeholder="请输入"
></el-input>
</el-form-item> </el-form-item>
</el-col> </el-col>
<el-col :span="12"> <el-col :span="12">
<el-form-item <el-form-item label="物资类型" prop="ldTwoOutStorage.materialType">
label="物资类型" <el-select v-model="sizeForm.ldTwoOutStorage.materialType" placeholder="请选择" style="width: 100%"
prop="ldTwoOutStorage.materialType" :disabled="outDialogType != 'add'">
>
<el-select
v-model="sizeForm.ldTwoOutStorage.materialType"
placeholder="请选择"
style="width: 100%"
:disabled="outDialogType != 'add'"
>
<el-option label="办公室物资" value="1"></el-option> <el-option label="办公室物资" value="1"></el-option>
<el-option label="其他物资" value="2"></el-option> <el-option label="其他物资" value="2"></el-option>
</el-select> </el-select>
@ -58,120 +32,59 @@
</el-col> </el-col>
<el-col :span="12"> <el-col :span="12">
<el-form-item label="部门" prop="ldTwoOutStorage.departmentInfo"> <el-form-item label="部门" prop="ldTwoOutStorage.departmentInfo">
<el-select <el-select v-model="sizeForm.ldTwoOutStorage.departmentInfo" placeholder="请选择" style="width: 100%"
v-model="sizeForm.ldTwoOutStorage.departmentInfo" :disabled="outDialogType != 'add'" @change="deptChange" clearable filterable value-key="departmentId">
placeholder="请选择" <el-option v-for="item in departmentOptions" :key="item.departmentId" :label="item.department"
style="width: 100%" :value="item"></el-option>
:disabled="outDialogType != 'add'"
@change="deptChange"
clearable
filterable
value-key="departmentId"
>
<el-option
v-for="item in departmentOptions"
:key="item.departmentId"
:label="item.department"
:value="item"
></el-option>
</el-select> </el-select>
</el-form-item> </el-form-item>
</el-col> </el-col>
<el-col :span="12"> <el-col :span="12">
<el-form-item label="领用人" prop="ldTwoOutStorage.proposerInfo"> <el-form-item label="领用人" prop="ldTwoOutStorage.proposerInfo">
<el-select <el-select v-model="sizeForm.ldTwoOutStorage.proposerInfo" placeholder="请选择" style="width: 100%"
v-model="sizeForm.ldTwoOutStorage.proposerInfo" :disabled="sizeForm.departmentId == '' || outDialogType == 'details'
placeholder="请选择" " clearable filterable value-key="userId" @change="proposerChange">
style="width: 100%" <el-option v-for="item in userOptions" :key="item.userId" :label="item.name" :value="item">
:disabled="
sizeForm.departmentId == '' || outDialogType == 'details'
"
clearable
filterable
value-key="userId"
@change="proposerChange"
>
<el-option
v-for="item in userOptions"
:key="item.userId"
:label="item.name"
:value="item"
>
</el-option> </el-option>
</el-select> </el-select>
</el-form-item> </el-form-item>
</el-col> </el-col>
<el-col :span="12"> <el-col :span="12">
<el-form-item label="物资分组" prop="ldTwoOutStorage.groupName"> <el-form-item label="物资分组" prop="ldTwoOutStorage.groupName">
<el-select <el-select v-model="sizeForm.ldTwoOutStorage.groupName" placeholder="请选择" style="width: 100%"
v-model="sizeForm.ldTwoOutStorage.groupName" :disabled="outDialogType != 'add'" clearable filterable value-key="departmentId"
placeholder="请选择" @change="groupNameChange">
style="width: 100%" <el-option v-for="item in groupNameOptions" :key="item.groupName" :label="item.groupName"
:disabled="outDialogType != 'add'" :value="item.groupName"></el-option>
clearable
filterable
value-key="departmentId"
@change="groupNameChange"
>
<el-option
v-for="item in groupNameOptions"
:key="item.groupName"
:label="item.groupName"
:value="item.groupName"
></el-option>
</el-select> </el-select>
</el-form-item> </el-form-item>
</el-col> </el-col>
<el-col :span="12" v-if="outDialogType == 'details'"> <el-col :span="12" v-if="outDialogType == 'details'">
<el-form-item label="填报人"> <el-form-item label="填报人">
<el-input <el-input v-model="sizeForm.ldTwoOutStorage.shipperName" :disabled="outDialogType != 'add'"></el-input>
v-model="sizeForm.ldTwoOutStorage.shipperName"
:disabled="outDialogType != 'add'"
></el-input>
</el-form-item> </el-form-item>
</el-col> </el-col>
</el-row> </el-row>
<div class="form-title">{{ outDateInfo }} 出库信息</div> <div class="form-title">{{ outDateInfo }} 出库信息</div>
<div v-if="sizeForm.ldTwoOutStorage.groupName !== '自由出库'"> <div v-if="sizeForm.ldTwoOutStorage.groupName !== '自由出库'">
<el-table <el-table :data="groupTableData" style="width: 100%" border ref="groupTable"
:data="groupTableData" @expand-change="handleExpandChange">
style="width: 100%"
border
ref="groupTable"
@expand-change="handleExpandChange"
>
<!-- 展开行详情 --> <!-- 展开行详情 -->
<el-table-column type="expand"> <el-table-column type="expand">
<template slot-scope="props"> <template slot-scope="props">
<!-- 关联表单列表带复选框 --> <!-- 关联表单列表带复选框 -->
<el-table <el-table :data="props.row.twoInventoryVOList || []" size="mini" style="width: 100%"
:data="props.row.twoInventoryVOList || []"
size="mini"
style="width: 100%"
@selection-change=" @selection-change="
(val) => handleSelectionChange(val, props.row) (val) => handleSelectionChange(val, props.row)
" " border :row-key="getRowKeyId" ref="nestedTable" v-if="props.row.twoInventoryVOList">
border
:row-key="getRowKeyId"
ref="nestedTable"
>
<!-- <el-table-column
type="selection"
width="55"
:selectable="isRowSelectable"
/> -->
<el-table-column label="选择" width="55"> <el-table-column label="选择" width="55">
<template slot-scope="scope"> <template slot-scope="scope">
<el-checkbox <el-checkbox v-model="scope.row._selected" :disabled="!isRowSelectable(scope.row)" @change="
v-model="scope.row._selected"
:disabled="!isRowSelectable(scope.row)"
@change="
(checked) => (checked) =>
handleRowSelect(checked, scope.row, props.row) handleRowSelect(checked, scope.row, props.row)
" " />
/>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column type="index" label="#" width="55" /> <el-table-column type="index" label="#" width="55" />
@ -179,20 +92,25 @@
<el-table-column label="物料编码" prop="materialCode" /> <el-table-column label="物料编码" prop="materialCode" />
<el-table-column label="规格型号" prop="model" /> <el-table-column label="规格型号" prop="model" />
<el-table-column label="数量" prop="inventory" /> <el-table-column label="数量" prop="inventory" />
<el-table-column label="实际使用人" prop="userInfo">
<template slot-scope="scope">
<el-select v-model="scope.row.userInfo" placeholder="请选择" style="width: 100%" :disabled="sizeForm.departmentId == '' || outDialogType == 'details'
" clearable filterable value-key="userId"
@change="(val) => proposerChangeTable(val, scope.$index, props.$index)"
v-if="scope.row.type == 'NY'">
<el-option v-for="item in userOptions" :key="item.userId" :label="item.name" :value="item">
</el-option>
</el-select>
<span v-else>-</span>
</template>
</el-table-column>
<el-table-column label="本次出库数量" prop="num"> <el-table-column label="本次出库数量" prop="num">
<template slot-scope="scope"> <template slot-scope="scope">
<el-input-number <el-input-number size="mini" v-model="scope.row.num" :min="0" :max="getMaxQuantity(scope.row)"
size="mini" style="width: 100%" :disabled="scope.row.type === 'NY'" @change="
v-model="scope.row.num"
:min="0"
:max="getMaxQuantity(scope.row)"
style="width: 100%"
:disabled="scope.row.type === 'NY'"
@change="
(newValue) => (newValue) =>
handleQuantityChange(newValue, scope.$index) handleQuantityChange(newValue, scope.$index)
" "></el-input-number>
></el-input-number>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column label="单价" prop="unitPrice" width="80" /> <el-table-column label="单价" prop="unitPrice" width="80" />
@ -210,39 +128,16 @@
</div> </div>
<div v-if="sizeForm.ldTwoOutStorage.groupName == '自由出库'"> <div v-if="sizeForm.ldTwoOutStorage.groupName == '自由出库'">
<el-button <el-button type="primary" size="mini" style="margin-bottom: 18px" @click="categoryHandle"
type="primary" v-if="outDialogType != 'details'">新增</el-button>
size="mini" <el-table :data="sizeForm.ldTwoOutStorageDetailList" border style="width: 100%" ref="table">
style="margin-bottom: 18px"
@click="categoryHandle"
v-if="outDialogType != 'details'"
>新增</el-button
>
<el-table
:data="sizeForm.ldTwoOutStorageDetailList"
border
style="width: 100%"
ref="table"
>
<el-table-column type="expand"> <el-table-column type="expand">
<template slot-scope="props"> <template slot-scope="props">
<el-table <el-table :data="scope.row.twoInventoryVOList" border style="width: 100%"
:data="scope.row.twoInventoryVOList" v-if="scope.row.twoInventoryVOList">
border <el-table-column prop="materialName" label="物资名称"></el-table-column>
style="width: 100%" <el-table-column prop="materialCode" label="物资编码"></el-table-column>
> <el-table-column prop="type" label="物资类型"></el-table-column>
<el-table-column
prop="materialName"
label="物资名称"
></el-table-column>
<el-table-column
prop="materialCode"
label="物资编码"
></el-table-column>
<el-table-column
prop="type"
label="物资类型"
></el-table-column>
<el-table-column prop="num" label="数量"></el-table-column> <el-table-column prop="num" label="数量"></el-table-column>
</el-table> </el-table>
</template> </template>
@ -250,10 +145,7 @@
<el-table-column prop="materialCode" label="物资编码"> <el-table-column prop="materialCode" label="物资编码">
</el-table-column> </el-table-column>
<el-table-column <el-table-column prop="materialName" label="物资名称"></el-table-column>
prop="materialName"
label="物资名称"
></el-table-column>
<el-table-column prop="model" label="规格/型号"> <el-table-column prop="model" label="规格/型号">
</el-table-column> </el-table-column>
<el-table-column prop="type" label="类别"> <el-table-column prop="type" label="类别">
@ -268,35 +160,30 @@
</template> </template>
</el-table-column> </el-table-column>
<el-table-column prop="unit" label="单位"> </el-table-column> <el-table-column prop="unit" label="单位"> </el-table-column>
<el-table-column label="实际使用人" prop="userInfo">
<template slot-scope="scope">
<el-select v-model="scope.row.userInfo" placeholder="请选择" style="width: 100%" :disabled="sizeForm.departmentId == '' || outDialogType == 'details'
" clearable filterable value-key="userId"
@change="(val) => proposerChangeTable(val, scope.$index, 0)" v-if="scope.row.type == 'NY'">
<el-option v-for="item in userOptions" :key="item.userId" :label="item.name" :value="item">
</el-option>
</el-select>
<span v-else>-</span>
</template>
</el-table-column>
<el-table-column prop="num" label="数量"> <el-table-column prop="num" label="数量">
<template slot-scope="scope"> <template slot-scope="scope">
<el-input-number <el-input-number size="mini" v-model="scope.row.num" :min="0" :max="getMaxQuantity(scope.row)"
size="mini" style="width: 100%" :disabled="outDialogType != 'add' || scope.row.type === 'NY'
v-model="scope.row.num" " @change="
:min="0"
:max="getMaxQuantity(scope.row)"
style="width: 100%"
:disabled="
outDialogType != 'add' || scope.row.type === 'NY'
"
@change="
(newValue) => handleQuantityChange(newValue, scope.$index) (newValue) => handleQuantityChange(newValue, scope.$index)
" "></el-input-number>
></el-input-number>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column <el-table-column label="操作" width="100" v-if="outDialogType != 'details'">
label="操作"
width="100"
v-if="outDialogType != 'details'"
>
<template slot-scope="scope"> <template slot-scope="scope">
<div :disabled="outDialogType == 'details'"> <div :disabled="outDialogType == 'details'">
<el-button <el-button type="text" size="mini" @click="handleDelete(scope.$index, scope.row)">
type="text"
size="mini"
@click="handleDelete(scope.$index, scope.row)"
>
删除 删除
</el-button> </el-button>
</div> </div>
@ -307,12 +194,7 @@
<div class="form-title" v-if="outDialogType != 'details'"> <div class="form-title" v-if="outDialogType != 'details'">
出库账目表格 出库账目表格
</div> </div>
<el-table <el-table :data="statisticsList" border style="width: 100%" v-if="outDialogType != 'details'">
:data="statisticsList"
border
style="width: 100%"
v-if="outDialogType != 'details'"
>
<el-table-column prop="date" label="当前库存" align="center"> <el-table-column prop="date" label="当前库存" align="center">
<el-table-column prop="materialCode" label="编码"> <el-table-column prop="materialCode" label="编码">
</el-table-column> </el-table-column>
@ -363,24 +245,13 @@
<span slot="footer" class="dialog-footer"> <span slot="footer" class="dialog-footer">
<el-button @click="handleCloseDetail()"> </el-button> <el-button @click="handleCloseDetail()"> </el-button>
<el-button <el-button v-if="outDialogType != 'details'" type="primary" @click="sumbit()"> </el-button>
v-if="outDialogType != 'details'"
type="primary"
@click="sumbit()"
> </el-button
>
</span> </span>
</el-dialog> </el-dialog>
<!-- 新增数据 --> <!-- 新增数据 -->
<categoryDialog <categoryDialog v-if="categoryVisible" :categoryVisible="categoryVisible" :selectionData="selectionData"
v-if="categoryVisible" :departmentId="sizeForm.ldTwoOutStorage.departmentId" :categoryDialogTitle="categoryDialogTitle"
:categoryVisible="categoryVisible" @confirm="confirm" @categoryClose="categoryClose"></categoryDialog>
:selectionData="selectionData"
:departmentId="sizeForm.ldTwoOutStorage.departmentId"
:categoryDialogTitle="categoryDialogTitle"
@confirm="confirm"
@categoryClose="categoryClose"
></categoryDialog>
</div> </div>
</template> </template>
<script> <script>
@ -651,24 +522,33 @@ export default {
} }
}, },
getOutGroupName() { getOutGroupName() {
// this.groupNameOptions = [
// {
// groupIds: "83,85",
// groupName: "",
// },
// {
// groupIds: null,
// groupName: "",
// },
// ];
getOutGroupName().then((res) => { getOutGroupName().then((res) => {
this.groupNameOptions = res.data.result; this.groupNameOptions = res.data.result;
}); });
}, },
// //
getStatistics() { getStatistics() {
getStatistics(this.sizeForm.ldTwoOutStorageDetailList).then((res) => { let arr = []
if (this.sizeForm.ldTwoOutStorage.groupName == '自由出库') {
arr = this.sizeForm.ldTwoOutStorageDetailList
} else {
this.groupTableData.forEach(group => {
if (group.twoInventoryVOList && group.twoInventoryVOList.length > 0) {
const selectedItems = group.twoInventoryVOList.filter(item => item._selected);
selectedItems.forEach(item => {
// num, userId
arr.push({
...item,
num: Number(item.num) || 0,
unitPrice: Number(item.unitPrice) || 0
});
});
}
});
}
getStatistics(arr).then((res) => {
this.statisticsList = res.data.result; this.statisticsList = res.data.result;
if (this.sizeForm.ldTwoOutStorage.groupName == '自由出库') {
this.statisticsList = this.statisticsList.map((stat) => { this.statisticsList = this.statisticsList.map((stat) => {
const detail = this.sizeForm.ldTwoOutStorageDetailList.find( const detail = this.sizeForm.ldTwoOutStorageDetailList.find(
(item) => item.materialCode === stat.materialCode (item) => item.materialCode === stat.materialCode
@ -680,6 +560,23 @@ export default {
totalQuantity: stat.num - detail.num, totalQuantity: stat.num - detail.num,
}; };
}); });
}else{
this.statisticsList = this.statisticsList.map((stat) => {
const detail = arr.find(
(item) => item.id === stat.id
);
console.log(90909090,detail)
return {
...stat,
theOutboundQuantity: detail.num || 1, //
unitPrice: detail.unitPrice,
totalQuantity: stat.num - detail.num,
};
});
}
}); });
}, },
// //
@ -800,10 +697,21 @@ export default {
}, },
// //
proposerChange(value) { proposerChange(value) {
console.log("领用人", value);
this.sizeForm.ldTwoOutStorage.proposerId = value.userId; this.sizeForm.ldTwoOutStorage.proposerId = value.userId;
this.sizeForm.ldTwoOutStorage.proposerName = value.name; this.sizeForm.ldTwoOutStorage.proposerName = value.name;
}, },
// 使
proposerChangeTable(val, index, v) {
if (this.sizeForm.ldTwoOutStorage.groupName !== '自由出库') {
this.groupTableData[v].twoInventoryVOList[index].userName = val.name;
this.groupTableData[v].twoInventoryVOList[index].userId = val.userId;
} else {
this.sizeForm.ldTwoOutStorageDetailList[index].userName = val.name;
this.sizeForm.ldTwoOutStorageDetailList[index].userId = val.userId;
}
},
handleCloseDetail() { handleCloseDetail() {
this.outDialogVisible = false; this.outDialogVisible = false;
this.$emit("handleCloseDetail"); this.$emit("handleCloseDetail");
@ -829,8 +737,8 @@ export default {
if (this.sizeForm.groupName != "自由出库") { if (this.sizeForm.groupName != "自由出库") {
this.groupTableData = res.data.result.ldTwoOutStorageDetailList; this.groupTableData = res.data.result.ldTwoOutStorageDetailList;
this.groupTableData.forEach(item=>{ this.groupTableData.forEach(item => {
item.applyNum=item.num item.applyNum = item.num
}) })
} }
// this.sizeForm.ldTwoOutStorage.proposerInfo={} // this.sizeForm.ldTwoOutStorage.proposerInfo={}
@ -852,21 +760,20 @@ export default {
}, },
// //
sumbit() { sumbit() {
console.log("form", this.sizeForm);
this.$refs.dynamicValidateForm.validate((valid) => { this.$refs.dynamicValidateForm.validate((valid) => {
if (valid) { if (valid) {
// ===== ===== // ===== =====
if (this.sizeForm.ldTwoOutStorage.groupName !== "自由出库") { if (this.sizeForm.ldTwoOutStorage.groupName !== "自由出库") {
let hasError = false; let hasError = false;
let finalDetailList = []; //
for (const group of this.groupTableData) { for (const group of this.groupTableData) {
if ( if (
!group.twoInventoryVOList || !group.twoInventoryVOList ||
group.twoInventoryVOList.length === 0 group.twoInventoryVOList.length === 0
) { ) {
this.$message.error( this.$message.error(
`分组【${ `分组【${group.materialName || group.materialCode
group.materialName || group.materialCode
}下无可出库物资` }下无可出库物资`
); );
hasError = true; hasError = true;
@ -880,13 +787,24 @@ export default {
if (selectedItems.length === 0) { if (selectedItems.length === 0) {
this.$message.error( this.$message.error(
`分组【${ `分组【${group.materialName || group.materialCode
group.materialName || group.materialCode
}未选择任何物资` }未选择任何物资`
); );
hasError = true; hasError = true;
break; break;
} }
// --- 使 ---
const missingUserItem = selectedItems.find(
(item) => item.type === "NY" && (!item.userId || item.userId === "")
);
if (missingUserItem) {
this.$message.error(
`分组【${group.materialName || group.materialCode}】中,物资【${missingUserItem.materialName}】为耐用品,请选择实际使用人`
);
hasError = true;
break;
}
const totalSelectedNum = selectedItems.reduce((sum, item) => { const totalSelectedNum = selectedItems.reduce((sum, item) => {
return sum + (Number(item.num) || 0); return sum + (Number(item.num) || 0);
@ -896,17 +814,30 @@ export default {
if (totalSelectedNum !== applyNum) { if (totalSelectedNum !== applyNum) {
this.$message.error( this.$message.error(
`分组【${ `分组【${group.materialName || group.materialCode
group.materialName || group.materialCode
}已选物资出库数量总和${totalSelectedNum}与申请数量${applyNum}不一致` }已选物资出库数量总和${totalSelectedNum}与申请数量${applyNum}不一致`
); );
hasError = true; hasError = true;
break; break;
} }
//
// proposerChangeTable userId/userName
selectedItems.forEach(item => {
finalDetailList.push({
...item,
//
num: Number(item.num) || 0,
unitPrice: Number(item.unitPrice) || 0
});
});
} }
if (hasError) { if (hasError) {
return; // return; //
} }
// sizeForm
this.sizeForm.ldTwoOutStorageDetailList = finalDetailList;
console.log("非自由出库合并后的明细数据:", finalDetailList);
} }
// ===== ===== // ===== =====
@ -918,8 +849,18 @@ export default {
this.$message.error("请至少选择一项物资"); this.$message.error("请至少选择一项物资");
return; return;
} }
} const freeMissingUser = this.sizeForm.ldTwoOutStorageDetailList.find(
(item) => item.type === "NY" && (!item.userId || item.userId === "")
);
if (freeMissingUser) {
this.$message.error(
`物资【${freeMissingUser.materialName}】为耐用品,请选择实际使用人`
);
return;
}
}
console.log("form", this.sizeForm);
submit(this.sizeForm).then((res) => { submit(this.sizeForm).then((res) => {
this.$message({ this.$message({
type: "success", type: "success",
@ -951,6 +892,7 @@ export default {
padding-right: 10px; padding-right: 10px;
/* 预留滚动条空间 */ /* 预留滚动条空间 */
} }
::v-deep.el-table th.el-table__cell { ::v-deep.el-table th.el-table__cell {
background: #f5f7fa; background: #f5f7fa;
font-weight: 500; font-weight: 500;

Loading…
Cancel
Save