二级库出库调整

master
taozi 3 months ago
parent 63cf4da610
commit 3b448d4f61
  1. 42
      src/views/firstOrder/components/outDialog.vue
  2. 262
      src/views/secondOrder/components/categoryDialog copy.vue
  3. 129
      src/views/secondOrder/components/categoryDialog.vue
  4. 43
      src/views/secondOrder/components/outDialog.vue

@ -554,22 +554,26 @@ export default {
return department ? department.department : ''; return department ? department.department : '';
}, },
// //
async getMaterialList() { async getMaterialList() {
this.loading = true this.loading = true
this.consumableVisible = false; this.consumableVisible = false; //
try { try {
if (this.sizeForm.optionType === "NY" && this.outDialogType !== 'details') { //
this.consumableVisible = true if (this.sizeForm.optionType === "NY" &&
} else { this.outDialogType !== 'details' &&
const res = await getMaterialList({ optionType: this.sizeForm.optionType }) this.sizeForm.options === 2) {
this.materials = res.data.result this.consumableVisible = true
} } else if (this.sizeForm.optionType === "YH" && this.outDialogType !== 'details') {
} catch (error) { //
this.$message.error("获取数据来源失败,请重试"); const res = await getMaterialList({ optionType: this.sizeForm.optionType })
} finally { this.materials = res.data.result
this.loading = false; }
} } catch (error) {
}, this.$message.error("获取数据来源失败,请重试");
} finally {
this.loading = false;
}
},
// //
handleMaterialChange(row, index) { handleMaterialChange(row, index) {
this.sizeForm.inTableData[index].materialId = row.materialId this.sizeForm.inTableData[index].materialId = row.materialId
@ -693,16 +697,16 @@ export default {
// //
radioChange() { radioChange() {
this.sizeForm.inTableData = [] this.sizeForm.inTableData = []
this.sizeForm.optionType = '';
this.inBatchDialogVisible = false;
this.consumableVisible = false; this.consumableVisible = false;
this.inBatchDialogVisible = false;
this.batchSelectionVisible = false; this.batchSelectionVisible = false;
this.sizeForm.optionType = '';
this.batchTableData = []; this.batchTableData = [];
if (this.sizeForm.options === 1) { if (this.sizeForm.options === 1) {
this.getQuarterList() this.getQuarterList()
this.inBatchDialogVisible = true this.inBatchDialogVisible = true
this.inBatchForm.batchType = '', this.inBatchForm.batchType = '',
this.inBatchForm.department = '' this.inBatchForm.department = ''
this.inBatchForm.optionType = '' this.inBatchForm.optionType = ''
} }
}, },

@ -0,0 +1,262 @@
<template>
<el-dialog :close-on-click-modal="false" :title="categoryDialogTitle" :visible.sync="categoryVisible"
:append-to-body="true" width="70%" @close="handleCloseDetail" fullscreen>
<el-tabs v-model="transactionType" @tab-click="handleTabClick">
<el-tab-pane label="易耗品" name="YH"></el-tab-pane>
<el-tab-pane label="耐用品" name="NY"></el-tab-pane>
</el-tabs>
<avue-crud :option="option" :table-loading="loading" :data="data" ref="crud" v-model="form" :page.sync="page"
:permission="permissionList" @row-del="rowDel" @search-change="searchChange" @search-reset="searchReset"
@selection-change="selectionChange" @current-change="currentChange" @size-change="sizeChange"
@refresh-change="refreshChange" @on-load="onLoad" @row-change="handleRowChange">
</avue-crud>
<div slot="footer" class="dialog-footer">
<el-button @click="handleCancel">取消</el-button>
<el-button type="primary" @click="handleConfirm">确定</el-button>
</div>
</el-dialog>
</template>
<script>
import { getList } from "@/api/secondOrder/list.js";
import { getList as fetchDurableApi } from "@/api/materials/expend";
export default {
props: {
categoryVisible: {
type: Boolean,
default: false
},
categoryDialogTitle: {
type: String,
default: ''
},
departmentId: {
type: String,
default: ''
},
selectionData: {
type: Object,
default: []
}
},
data() {
return {
form: {},
selectionList: [],
newselection: [],
query: {},
loading: true,
page: {
pageSize: 10,
currentPage: 1,
total: 0,
},
option: {
reserveSelection: true,
calcHeight: 30,
tip: false,
searchShow: true,
searchMenuSpan: 18,
border: true,
index: true,
selection: true,
viewBtn: true,
dialogClickModal: false,
menu: false,
addBtn: false,
printBtn: false,
refreshBtn: false,
gridBtn: false,
gridBackgroundImage: false,
gridSpan: false,
filterBtn: false,
columnBtn: false,
menuAlign: "left",
searchMenuPosition: "right",
menuWidth: 80,
selectable: (row, index) => row.num !== 0,
column: [
{
label: "存货编号",
prop: "materialCode",
headerAlign: "center",
align: "center",
},
{
label: "存货名称",
prop: "materialName",
search: true,
headerAlign: "center",
align: "left",
},
{
label: "规格型号",
prop: "model",
headerAlign: "center",
align: "left",
},
{
label: "类别",
prop: "type",
search: false,
type: "select",
headerAlign: "center",
align: "center",
value: "NY",
disabled: true,
dicData: [
{
label: "易耗品",
value: "YH",
},
{
label: "耐用品",
value: "NY",
},
],
},
{
label: "计量单位",
prop: "unit",
headerAlign: "center",
align: "center",
},
{
label: "数量",
prop: "num",
headerAlign: "center",
align: "center",
},
{
label: "单价",
prop: "unitPrice",
headerAlign: "center",
align: "center",
formatter: (row, column) => {
const value = row.unitPrice;
if (value === null || value === undefined || value === "") {
return "-";
}
return value;
}
},
],
},
data: [],
dialogLogVisible: false,
transactionType: "YH",
tableData: [],
ckTable: [],
rkTable: [],
currentRow: null,
allSelectedList: [],
isUpdatingSelection: false,
}
},
mounted() {
this.onLoad(this.page);
},
methods: {
//
searchReset() {
this.query = {};
this.onLoad(this.page);
},
searchChange(params, done) {
this.query = params;
this.page.currentPage = 1;
this.onLoad(this.page, params);
done();
},
//
selectionChange(selection) {
console.log(this.selectionData, '---selectionData')
const currentPageIds = this.selectionData.map(item => item.id)
let arr = selection.filter(item => !currentPageIds.includes(item.id)) //
const selectionWithTwoInventoryId = arr.map(item => ({
...item,
twoInventoryId: item.id
}))
this.allSelectedList.push(...selectionWithTwoInventoryId);
this.allSelectedList = this.uniqueById(this.allSelectedList);
},
//
uniqueById(arr) {
const uniqueObj = {};
arr.forEach(item => {
if (item.id && !uniqueObj[item.id]) {
uniqueObj[item.id] = item;
}
});
return Object.values(uniqueObj);
},
//
handleConfirm() {
const uniqueList = this.uniqueById(this.allSelectedList);
this.$emit("confirm", uniqueList);
},
handleCloseDetail() {
this.$emit('handleCloseDetail')
},
selectionClear() {
this.allSelectedList = []
if (this.$refs.crud) {
this.$refs.crud.toggleSelection()
}
},
currentChange(currentPage) {
this.page.currentPage = currentPage;
this.onLoad(this.page, this.query);
},
sizeChange(pageSize) {
this.page.pageSize = pageSize;
this.onLoad(this.page, this.query);
},
refreshChange() {
this.onLoad(this.page, this.query);
},
handleTabClick() {
this.page.currentPage = 1;
this.onLoad(this.page);
},
onLoad(page, params = {}) {
this.loading = true;
const requestParams = Object.assign({}, params, this.query, {
num: 0,
departmentId: this.departmentId
});
const apiPromise = this.transactionType === "YH"
? getList(page.currentPage, page.pageSize, requestParams)
: fetchDurableApi(page.currentPage, page.pageSize, requestParams);
apiPromise.then((res) => {
this.data = res.data.result.list;
this.page.total = res.data.result.total;
}).catch(error => {
this.$message.error('加载数据失败: ' + error.message);
}).finally(() => {
this.loading = false;
});
},
handleCancel() {
this.categoryVisible = false
}
},
}
</script>
<style lang="scss" scoped>
::v-deep.el-dialog__footer {
position: fixed !important;
bottom: 0 !important;
right: 0 !important;
}
::v-deep.dialog-content {
max-height: calc(100vh - 200px);
overflow-y: auto;
padding-right: 10px;
overflow-x: hidden;
}
</style>

@ -33,12 +33,17 @@ export default {
departmentId: { departmentId: {
type: [String, Number], type: [String, Number],
default: '' default: ''
},
selectionData: {
type: Array,
default: () => []
} }
}, },
data() { data() {
return { return {
form: {}, form: {},
selectionList: [], selectionList: [],
newselection: [],
query: {}, query: {},
loading: true, loading: true,
page: { page: {
@ -139,17 +144,18 @@ export default {
}, },
data: [], data: [],
dialogLogVisible: false, dialogLogVisible: false,
transactionType: "YH", // YHname transactionType: "YH",
tableData: [], tableData: [],
ckTable: [], ckTable: [],
rkTable: [], rkTable: [],
currentRow: null, currentRow: null,
allSelectedList: [], // allSelectedList: [],
isUpdatingSelection: false, // data isUpdatingSelection: false,
} }
}, },
mounted() { mounted() {
// // 使selectionData
this.allSelectedList = [...this.selectionData];
this.onLoad(this.page); this.onLoad(this.page);
}, },
methods: { methods: {
@ -165,74 +171,141 @@ export default {
done(); done();
}, },
//
updateCurrentPageSelection() {
if (!this.$refs.crud || !this.data) return;
this.isUpdatingSelection = true;
const currentPageData = this.data || [];
//
this.$refs.crud.toggleSelection();
// allSelectedList
currentPageData.forEach((item) => {
const isSelected = this.allSelectedList.some(selectedItem =>
selectedItem.id === item.id
);
if (isSelected) {
this.$refs.crud.toggleRowSelection(item, true);
}
});
//
this.$nextTick(() => {
setTimeout(() => {
this.isUpdatingSelection = false
}, 100);
});
},
// //
selectionChange(selection) { selectionChange(selection) {
console.log("勾选选中", selection); if (this.isUpdatingSelection) {
return;
}
console.log('当前选择:', selection)
console.log('当前页面数据:', this.data)
console.log('当前全部勾选:', this.allSelectedList)
// ID
const currentPageIds = this.data.map(item => item.id); const currentPageIds = this.data.map(item => item.id);
this.allSelectedList = this.allSelectedList.filter(item =>
const otherPageSelected = this.allSelectedList.filter(item =>
!currentPageIds.includes(item.id) !currentPageIds.includes(item.id)
); );
const selectionWithTwoInventoryId = selection.map(item => ({
const currentSelected = selection.map(item => ({
...item, ...item,
twoInventoryId: item.twoInventoryId || item.id twoInventoryId: item.id
})); }));
this.allSelectedList.push(...selectionWithTwoInventoryId);
//
const combinedSelection = [
...otherPageSelected, //
...currentSelected //
];
// allSelectedList
this.allSelectedList = this.uniqueById(combinedSelection)
console.log('更新后的allSelectedList:', this.allSelectedList)
},
//
uniqueById(arr) {
const uniqueObj = {};
arr.forEach(item => {
if (item.id && !uniqueObj[item.id]) {
uniqueObj[item.id] = item;
}
});
return Object.values(uniqueObj);
}, },
// //
handleConfirm() { handleConfirm() {
this.$emit("confirm", this.allSelectedList); const uniqueList = this.uniqueById(this.allSelectedList)
this.$emit("confirm", uniqueList)
}, },
handleCloseDetail() { handleCloseDetail() {
this.$emit('handleCloseDetail') this.$emit('handleCloseDetail')
}, },
selectionClear() { selectionClear() {
this.allSelectedList = []; // this.allSelectedList = []
if (this.$refs.crud) { if (this.$refs.crud) {
this.$refs.crud.toggleSelection(); // this.$refs.crud.toggleSelection()
} }
}, },
currentChange(currentPage) { currentChange(currentPage) {
this.page.currentPage = currentPage; this.page.currentPage = currentPage;
this.onLoad(this.page, this.query); this.onLoad(this.page, this.query)
}, },
sizeChange(pageSize) { sizeChange(pageSize) {
this.page.pageSize = pageSize; this.page.pageSize = pageSize;
this.onLoad(this.page, this.query); this.onLoad(this.page, this.query)
}, },
refreshChange() { refreshChange() {
this.onLoad(this.page, this.query); this.onLoad(this.page, this.query)
}, },
//
handleTabClick() { handleTabClick() {
// 1 this.page.currentPage = 1
this.page.currentPage = 1; this.onLoad(this.page)
this.onLoad(this.page);
//
this.selectionClear();
}, },
onLoad(page, params = {}) { onLoad(page, params = {}) {
this.loading = true; this.loading = true
const requestParams = Object.assign({}, params, this.query, { const requestParams = Object.assign({}, params, this.query, {
num: 0, num: 0,
departmentId: this.departmentId departmentId: this.departmentId
}); });
const apiPromise = this.transactionType === "YH" const apiPromise = this.transactionType === "YH"
? getList(page.currentPage, page.pageSize, requestParams) ? getList(page.currentPage, page.pageSize, requestParams)
: fetchDurableApi(page.currentPage, page.pageSize, requestParams); : fetchDurableApi(page.currentPage, page.pageSize, requestParams)
apiPromise.then((res) => { apiPromise.then((res) => {
this.data = res.data.result.list; this.data = res.data.result.list
this.page.total = res.data.result.total; this.page.total = res.data.result.total
//
this.$nextTick(() => {
this.updateCurrentPageSelection()
});
}).catch(error => { }).catch(error => {
this.$message.error('加载数据失败: ' + error.message); this.$message.error('加载数据失败: ' + error.message)
}).finally(() => { }).finally(() => {
this.loading = false; this.loading = false;
}); })
}, },
handleCancel() { handleCancel() {
this.categoryVisible = false this.categoryVisible = false
} }

@ -79,7 +79,7 @@
</el-select> </el-select>
<span v-else> {{ scope.row.materialName }}</span> <span v-else> {{ scope.row.materialName }}</span>
</template> </template>
</el-table-column> --> </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="model" label="规格/型号"> </el-table-column>
<!-- <el-table-column prop="type" label="类别"> </el-table-column> --> <!-- <el-table-column prop="type" label="类别"> </el-table-column> -->
@ -135,7 +135,7 @@
<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> </span>
</el-dialog> </el-dialog>
<categoryDialog v-if="categoryVisible" :categoryVisible='categoryVisible' <categoryDialog v-if="categoryVisible" :categoryVisible='categoryVisible' :selectionData="selectionData"
:departmentId="sizeForm.ldTwoOutStorage.departmentId" :categoryDialogTitle="categoryDialogTitle" :departmentId="sizeForm.ldTwoOutStorage.departmentId" :categoryDialogTitle="categoryDialogTitle"
@confirm="confirm" @handleCloseDetail="handleCloseDetail"></categoryDialog> @confirm="confirm" @handleCloseDetail="handleCloseDetail"></categoryDialog>
</div> </div>
@ -201,6 +201,8 @@ export default {
outDialogVisible: false, outDialogVisible: false,
categoryVisible: false, categoryVisible: false,
categoryDialogTitle: '出库', categoryDialogTitle: '出库',
allSelectedList:[],
selectionData:[],
sizeForm: { sizeForm: {
ldTwoOutStorage: { ldTwoOutStorage: {
outDate: "", outDate: "",
@ -280,17 +282,32 @@ export default {
this.categoryVisible = true this.categoryVisible = true
}, },
confirm(allSelectedList) { confirm(allSelectedList) {
console.log('allSelectedList-------',allSelectedList)
// this.selectionData = allSelectedList
allSelectedList.map(item =>{
this.selectionData.push(item)
})
this.categoryVisible = false; this.categoryVisible = false;
const formattedList = allSelectedList.map(item => ({ //
...item, const newItems = allSelectedList.filter(newItem =>
// oldNum: item.num , !this.sizeForm.ldTwoOutStorageDetailList.some(
// newNum: item.num , oldItem => oldItem.id === newItem.id
num: item.type === "NY" ? 1 : item.num // 1 )
})); );
this.sizeForm.ldTwoOutStorageDetailList = formattedList; //
this.sizeForm.inAccountsTableData = JSON.parse(JSON.stringify(formattedList)); this.sizeForm.ldTwoOutStorageDetailList = [
...this.sizeForm.ldTwoOutStorageDetailList,
...newItems
];
console.log('ldTwoOutStorageDetailList--------',this.sizeForm.ldTwoOutStorageDetailList)
//
this.summaryTableData();
}, },
// categoryHandle() {
this.categoryVisible = true;
},
//
handleDelete(index, row) { handleDelete(index, row) {
this.sizeForm.ldTwoOutStorageDetailList.splice(index, 1) this.sizeForm.ldTwoOutStorageDetailList.splice(index, 1)
}, },
@ -309,7 +326,7 @@ export default {
// this.$set(this.sizeForm.inAccountsTableData, index, currentRow) // this.$set(this.sizeForm.inAccountsTableData, index, currentRow)
// this.sizeForm.inAccountsTableData[index] = currentRow // this.sizeForm.inAccountsTableData[index] = currentRow
// }, // },
handleQuantityChange(newValue, index) { handleQuantityChange(newValue, index) {
const currentRow = this.sizeForm.ldTwoOutStorageDetailList[index]; const currentRow = this.sizeForm.ldTwoOutStorageDetailList[index];
if (!currentRow) return; if (!currentRow) return;
if (currentRow.type === "NY") { if (currentRow.type === "NY") {
@ -324,7 +341,7 @@ export default {
currentRow.newNum = stockNum - newValue // currentRow.newNum = stockNum - newValue //
this.$set(this.sizeForm.ldTwoOutStorageDetailList, index, currentRow) this.$set(this.sizeForm.ldTwoOutStorageDetailList, index, currentRow)
this.$set(this.sizeForm.inAccountsTableData, index, { ...currentRow }) this.$set(this.sizeForm.inAccountsTableData, index, { ...currentRow })
}, },
// //
updateGlobalTotal() { updateGlobalTotal() {

Loading…
Cancel
Save