二级出库修改

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

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

Loading…
Cancel
Save