bug修改

This commit is contained in:
cookiemy 2024-07-04 14:21:40 +08:00
parent 3e03b110e9
commit 4c820468b7
11 changed files with 1115 additions and 789 deletions

View File

@ -185,7 +185,6 @@
<el-input @blur="ChangeShop(row)" v-model="row.productCode" /> <el-input @blur="ChangeShop(row)" v-model="row.productCode" />
<div style="display: flex; align-items: center"> <div style="display: flex; align-items: center">
<el-popover <el-popover
:visible="visible"
v-model="row.popoverVisible" v-model="row.popoverVisible"
placement="bottom" placement="bottom"
trigger="click" trigger="click"
@ -785,8 +784,9 @@ export default {
filePaths.push(file.filePath); filePaths.push(file.filePath);
} }
self.fileLists = filePaths; self.fileLists = filePaths;
console.log(self.fileLists, "self.fileLists");
let params = self.searchForm; let params = self.searchForm;
params.fileList = self.fileLists;
params.billItemList = billItemList; params.billItemList = billItemList;
console.log(params, "params"); console.log(params, "params");
self.loading = true; self.loading = true;
@ -1026,33 +1026,6 @@ export default {
} }
return sums; return sums;
}, },
// getSummarys({ columns, data }) {
// let sums = [];
// let totalPrice = 0;
// // ''
// sums.push("");
// columns.forEach((column, index) => {
// if (
// column.property == "purchaseMoney" ||
// column.property == "otherMoney" ||
// column.property == "allPrice"
// ) {
// const values = data.map((item) => Number(item[column.property]));
// const sum = values.reduce((prev, curr) => prev + curr, 0);
// sums[index] = sum; //
// if (column.property === "allPrice") {
// totalPrice = sum; // totalPrice
// }
// } else {
// sums.push(""); //
// }
// });
// this.totalPrices = totalPrice;
// console.log(this.totalPrices, "this.totalPrices");
// localStorage.setItem("totalPriced", this.totalPrices);
// this.searchForm.totalPrice = localStorage.getItem("totalPriced");
// return sums;
// },
getSummary({ columns, data }) { getSummary({ columns, data }) {
let sums = []; let sums = [];
let totalPrice = 0; let totalPrice = 0;

View File

@ -9,7 +9,6 @@
:show-close="false" :show-close="false"
append-to-body append-to-body
align-center align-center
> >
<template #header="{ close, titleId, titleClass }"> <template #header="{ close, titleId, titleClass }">
<div class="my-header d-b-c"> <div class="my-header d-b-c">
@ -292,26 +291,35 @@
<el-row :gutter="20" class="mt12"> <el-row :gutter="20" class="mt12">
<el-col :span="24"> <el-col :span="24">
<div class="form-item-container"> <div class="form-item-container">
<label class="form-item-label" <label class="form-item-label">图片/附件 </label>
>图片/附件
<el-button size="small" type="primary" icon="UploadFilled"
>点击上传</el-button
></label
>
<div class="form-item-content1"> <div class="form-item-content1">
<div class="content-box"> <div class="content-box">
<el-form-item label=""> <el-form-item label="" :label-width="formLabelWidth">
<div class="content-box-container"> <div class="draggable-list">
<el-image <draggable
style=" class="wrapper"
width: 48px; v-model="searchForm.fileList"
height: 48px;
margin-right: 12px;
"
src="/static/imgs/logo.png"
preview-src-list="[/static/imgs/logo.png]"
> >
</el-image> <template #item="{ element, index }">
<div class="item">
<img v-img-url="element.filePath" />
<a
href="javascript:void(0);"
class="delete-btn"
@click.stop="deleteImg(index)"
>
<el-icon>
<CloseBold />
</el-icon>
</a>
</div>
</template>
</draggable>
<div class="item img-select" @click="openUpload">
<el-icon>
<Plus />
</el-icon>
</div>
</div> </div>
</el-form-item> </el-form-item>
</div> </div>
@ -605,21 +613,39 @@ export default {
this.type = e; this.type = e;
this.isupload = true; this.isupload = true;
}, },
deleteImg(index) {
this.searchForm.imageList.splice(index, 1);
},
/*获取图片*/ /*获取图片*/
returnImgsFunc(e) { returnImgsFunc(e) {
if (e != null && e.length > 0) { console.log(this.searchForm);
for (let img of e) { if (e != null) {
if (!this.searchForm.fileList) { let imgs = this.searchForm.fileList.concat(e);
this.searchForm.fileList = []; this.searchForm.fileList = imgs;
//
for (let i = 0; i < imgs.length; i++) {
if (typeof imageId == "undefined") {
imgs[i].imageId = imgs[i].fileId;
} }
this.searchForm.fileList.push({
fileId: img.fileId,
filePath: img.filePath,
});
} }
} }
this.isupload = false; this.isupload = false;
console.log(this.searchForm.fileList, "this.searchForm.fileList ");
}, },
// returnImgsFunc(e) {
// if (e != null && e.length > 0) {
// for (let img of e) {
// if (!this.searchForm.fileList) {
// this.searchForm.fileList = [];
// }
// this.searchForm.fileList.push({
// fileId: img.fileId,
// filePath: img.filePath,
// });
// }
// }
// this.isupload = false;
// },
}, },
}; };
</script> </script>

View File

@ -99,7 +99,8 @@
border border
style="width: 100%" style="width: 100%"
@selection-change="handleSelectionChange" @selection-change="handleSelectionChange"
@row-click="handleRowClick" @row-click="handleRowClicks"
@row-dblclick="handleRowClick"
v-loading="loading" v-loading="loading"
show-summary show-summary
:summary-method="getSummarys" :summary-method="getSummarys"
@ -119,35 +120,57 @@
label="提醒" label="提醒"
width="100" width="100"
></el-table-column> ></el-table-column>
<!-- <el-table-column
prop="otherUnit"
label="订单标记"
width="100"
></el-table-column> -->
<!-- <el-table-column
prop="otherUnit"
label="剩余发货时间"
width="100"
></el-table-column> -->
<el-table-column <el-table-column
prop="availableAllNumber" prop="availableAllNumber"
label="商品总数" label="商品总数"
></el-table-column> ></el-table-column>
<el-table-column prop="fileUrls" label="系统图片"> <el-table-column prop="fileUrls" width="200" label="系统图片">
<template #default="scope"> <template #default="scope">
<el-image <el-popover placement="right-start" trigger="hover" width="24">
style="width: 50px; height: 50px" <template #reference>
:src="scope.row.fileUrls" <div v-if="scope.row.fileList && scope.row.fileList.length > 0">
:preview-src-list="[scope.row.fileUrls]" <el-avatar
></el-image> v-for="(file, index) in scope.row.fileList"
:key="index"
shape="square"
style="margin-bottom: 5px; margin-left: 5px"
:size="24"
:src="file"
/>
</div>
<div v-else>
<el-avatar
:size="24"
style="margin-left: 10px"
shape="square"
src="/static/imgs/imagerror.png"
/>
</div>
</template>
<template #default>
<div v-if="scope.row.fileList && scope.row.fileList.length > 0">
<el-avatar
v-for="(file, index) in scope.row.fileList"
:key="index"
:size="100"
style="margin-left: 20px"
shape="square"
:src="file"
/>
</div>
<div v-else>
<el-avatar
:size="24"
style="margin-left: 20px"
shape="square"
src="/static/imgs/imagerror.png"
/>
</div>
</template>
</el-popover>
</template> </template>
</el-table-column> </el-table-column>
<!-- <el-table-column prop="codeNum" label="商品概况"></el-table-column> -->
<el-table-column prop="remark" label="系统备注"></el-table-column> <el-table-column prop="remark" label="系统备注"></el-table-column>
<!-- <el-table-column
prop="codeNum"
label="买家留言/附加信息"
></el-table-column> -->
<el-table-column <el-table-column
prop="depotName" prop="depotName"
label="仓库" label="仓库"
@ -484,6 +507,9 @@ export default {
}, },
}, },
methods: { methods: {
isRootNode(row) {
return row.billItemList;
},
getSelectData() { getSelectData() {
SettingApi.regionList().then((res) => { SettingApi.regionList().then((res) => {
this.areaData = res.data; this.areaData = res.data;
@ -513,7 +539,14 @@ export default {
handleDeliveryChange(row) { handleDeliveryChange(row) {
this.getselect(row); this.getselect(row);
}, },
handleRowClicks() {
ElNotification({
type: "info",
title: "提示",
message: "双击列表行查看详情",
duration: 1000,
});
},
/*保存备注信息*/ /*保存备注信息*/
editRemark() { editRemark() {
let self = this; let self = this;

View File

@ -9,7 +9,6 @@
:show-close="false" :show-close="false"
append-to-body append-to-body
align-center align-center
> >
<template #header="{ close, titleId, titleClass }"> <template #header="{ close, titleId, titleClass }">
<div class="my-header d-b-c"> <div class="my-header d-b-c">
@ -203,10 +202,10 @@
</el-table-column> </el-table-column>
<el-table-column prop="commodityDecimal" label="吊牌价" width="100"> <el-table-column prop="commodityDecimal" label="吊牌价" width="100">
</el-table-column> </el-table-column>
<el-table-column prop="unitPrice" label="单价" width="100" <el-table-column prop="purchaseDecimal" label="单价" width="100"
><template #default="{ row }"> ><template #default="{ row }">
<el-input <el-input
v-model="row.unitPrice" v-model="row.purchaseDecimal"
label="单价" label="单价"
@blur="handleUnitPriceChange(row)" @blur="handleUnitPriceChange(row)"
/> />
@ -504,7 +503,7 @@ export default {
row.discountRate = 100; row.discountRate = 100;
} }
// //
row.discountPrice = (row.unitPrice * row.discountRate) / 100; row.discountPrice = (row.purchaseDecimal * row.discountRate) / 100;
// //
if (row.discountPrice && row.operNumber) { if (row.discountPrice && row.operNumber) {
@ -515,7 +514,7 @@ export default {
}, },
handleUnitPriceChange(row) { handleUnitPriceChange(row) {
// //
row.discountPrice = (row.unitPrice * row.discountRate) / 100; row.discountPrice = (row.purchaseDecimal * row.discountRate) / 100;
// //
if (row.discountPrice && row.operNumber) { if (row.discountPrice && row.operNumber) {
@ -529,7 +528,9 @@ export default {
localStorage.setItem("costPrice", row.costPrice); localStorage.setItem("costPrice", row.costPrice);
row.operNumber = 1; // 1 row.operNumber = 1; // 1
// 1 // 1
row.unitPrice = row.costPrice || 1; if (!row.purchaseDecimal) {
row.purchaseDecimal = row.costPrice || 1;
}
row.discountRate = row.discountRate || 100; row.discountRate = row.discountRate || 100;
row.purchaseCycle = row.purchaseCycle || 0; row.purchaseCycle = row.purchaseCycle || 0;
// //
@ -546,7 +547,7 @@ export default {
} }
if (row.materialUnit == row.productUnit.basicUnit) { if (row.materialUnit == row.productUnit.basicUnit) {
row.basicNumber = row.operNumber * 1; row.basicNumber = row.operNumber * 1;
row.unitPrice = row.unitPrice * 1; row.purchaseDecimal = row.purchaseDecimal * 1;
this.handleUnitPriceChange(row); this.handleUnitPriceChange(row);
} else { } else {
const deputyUnit = row.productUnit.deputyList.find( const deputyUnit = row.productUnit.deputyList.find(
@ -554,7 +555,7 @@ export default {
); );
if (deputyUnit) { if (deputyUnit) {
row.basicNumber = row.operNumber * deputyUnit.ratio; row.basicNumber = row.operNumber * deputyUnit.ratio;
row.unitPrice = row.unitPrice * deputyUnit.ratio; row.purchaseDecimal = row.purchaseDecimal * deputyUnit.ratio;
this.handleUnitPriceChange(row); this.handleUnitPriceChange(row);
} }
} }
@ -689,7 +690,7 @@ export default {
materialUnit: option.materialUnit, materialUnit: option.materialUnit,
operNumber: option.operNumber, operNumber: option.operNumber,
basicNumber: option.basicNumber, basicNumber: option.basicNumber,
unitPrice: option.unitPrice, purchaseDecimal: option.purchaseDecimal,
discountRate: option.discountRate, discountRate: option.discountRate,
discountPrice: option.discountPrice, discountPrice: option.discountPrice,
allPrice: option.allPrice, allPrice: option.allPrice,

View File

@ -9,7 +9,6 @@
:show-close="false" :show-close="false"
append-to-body append-to-body
align-center align-center
> >
<template #header="{ close, titleId, titleClass }"> <template #header="{ close, titleId, titleClass }">
<div class="my-header d-b-c"> <div class="my-header d-b-c">
@ -245,13 +244,17 @@
/> />
</template> </template>
</el-table-column> </el-table-column>
<el-table-column prop="commodityDecimal" label="吊牌价" width="100"> <el-table-column
prop="productExtend.commodityDecimal"
label="吊牌价"
width="100"
>
</el-table-column> </el-table-column>
<el-table-column prop="unitPrice" label="单价" width="100" <el-table-column prop="purchaseDecimal" label="单价" width="100"
><template #default="{ row }"> ><template #default="{ row }">
<el-input <el-input
:disabled="openDetail" :disabled="openDetail"
v-model="row.unitPrice" v-model="row.productExtend.purchaseDecimal"
label="单价" label="单价"
@blur="handleUnitPriceChange(row)" @blur="handleUnitPriceChange(row)"
/> />
@ -590,7 +593,8 @@ export default {
row.discountRate = 100; row.discountRate = 100;
} }
// //
row.discountPrice = (row.unitPrice * row.discountRate) / 100; row.discountPrice =
(row.productExtend.purchaseDecimal * row.discountRate) / 100;
// //
if (row.discountPrice && row.operNumber) { if (row.discountPrice && row.operNumber) {
@ -601,7 +605,8 @@ export default {
}, },
handleUnitPriceChange(row) { handleUnitPriceChange(row) {
// //
row.discountPrice = (row.unitPrice * row.discountRate) / 100; row.discountPrice =
(row.productExtend.purchaseDecimal * row.discountRate) / 100;
// //
if (row.discountPrice && row.operNumber) { if (row.discountPrice && row.operNumber) {
@ -615,7 +620,9 @@ export default {
localStorage.setItem("costPrice", row.costPrice); localStorage.setItem("costPrice", row.costPrice);
row.operNumber = 1; // 1 row.operNumber = 1; // 1
// 1 // 1
row.unitPrice = row.costPrice || 1; if (!row.productExtend.purchaseDecimal) {
row.productExtend.purchaseDecimal = row.costPrice || 1;
}
row.discountRate = row.discountRate || 10; row.discountRate = row.discountRate || 10;
// //
row.discountPrice = row.costPrice * row.discountRate; row.discountPrice = row.costPrice * row.discountRate;
@ -632,7 +639,8 @@ export default {
console.log(row, "row"); console.log(row, "row");
if (row.materialUnit == row.productExtend.productUnit.basicUnit) { if (row.materialUnit == row.productExtend.productUnit.basicUnit) {
row.basicNumber = row.operNumber * 1; row.basicNumber = row.operNumber * 1;
row.unitPrice = row.unitPrice * 1; row.productExtend.purchaseDecimal =
row.productExtend.purchaseDecimal * 1;
this.handleUnitPriceChange(row); this.handleUnitPriceChange(row);
} else { } else {
if (row.productExtend) { if (row.productExtend) {
@ -640,7 +648,8 @@ export default {
(unit) => unit.deputyUnitName === row.materialUnit (unit) => unit.deputyUnitName === row.materialUnit
); );
row.basicNumber = row.operNumber * deputyUnit.ratio; row.basicNumber = row.operNumber * deputyUnit.ratio;
row.unitPrice = row.unitPrice * deputyUnit.ratio; row.productExtend.purchaseDecimal =
row.productExtend.purchaseDecimal * deputyUnit.ratio;
this.handleUnitPriceChange(row); this.handleUnitPriceChange(row);
} else { } else {
const deputyUnits = row.productUnit.deputyList.find( const deputyUnits = row.productUnit.deputyList.find(
@ -648,7 +657,8 @@ export default {
); );
console.log(deputyUnits, "deputyUnit2"); console.log(deputyUnits, "deputyUnit2");
row.basicNumber = row.operNumber * deputyUnits.ratio; row.basicNumber = row.operNumber * deputyUnits.ratio;
row.unitPrice = row.unitPrice * deputyUnits.ratio; row.productExtend.purchaseDecimal =
row.productExtend.purchaseDecimal * deputyUnits.ratio;
this.handleUnitPriceChange(row); this.handleUnitPriceChange(row);
} }
} }
@ -775,7 +785,7 @@ export default {
materialUnit: option.materialUnit, materialUnit: option.materialUnit,
operNumber: option.operNumber, operNumber: option.operNumber,
basicNumber: option.basicNumber, basicNumber: option.basicNumber,
unitPrice: option.unitPrice, purchaseDecimal: option.productExtend.purchaseDecimal,
discountRate: option.discountRate, discountRate: option.discountRate,
discountPrice: option.discountPrice, discountPrice: option.discountPrice,
allPrice: option.allPrice, allPrice: option.allPrice,

File diff suppressed because it is too large Load Diff

View File

@ -9,7 +9,6 @@
:show-close="false" :show-close="false"
append-to-body append-to-body
align-center align-center
> >
<template #header="{ close, titleId, titleClass }"> <template #header="{ close, titleId, titleClass }">
<div class="my-header d-b-c"> <div class="my-header d-b-c">
@ -118,7 +117,6 @@
style="width: 100%" style="width: 100%"
:tree-props="{ children: 'billItemList' }" :tree-props="{ children: 'billItemList' }"
@select="handleSelect" @select="handleSelect"
@select-all="handleSelectAll"
@selection-change="handleMainListSelectionChange" @selection-change="handleMainListSelectionChange"
v-loading="loading" v-loading="loading"
> >
@ -322,54 +320,85 @@ export default {
} }
}, },
methods: { methods: {
cancelAllChildSelection() {
this.productData.forEach((row) => {
if (this.isRootNode(row)) {
row.billItemList.forEach((child) => {
this.$refs.table.toggleRowSelection(child, false);
});
}
});
},
handleMainListSelectionChange(selection) { handleMainListSelectionChange(selection) {
this.selectedItems = selection; if (this.updating) return;
console.log(this.selectedItems, "this.selectedItems "); this.updating = true;
this.selectedItems = [...selection];
console.log(selection, "selection");
this.productData.forEach((row) => { this.productData.forEach((row) => {
if (this.isRootNode(row)) { if (this.isRootNode(row)) {
const allChildrenSelected = row.billItemList.every((child) => const allChildrenSelected = row.billItemList.every((child) =>
selection.includes(child) selection.includes(child)
); );
if (allChildrenSelected && !selection.includes(row)) { const anyChildSelected = row.billItemList.some((child) =>
selection.includes(child)
);
if (anyChildSelected && !selection.includes(row)) {
this.$refs.table.toggleRowSelection(row, true); this.$refs.table.toggleRowSelection(row, true);
} else if (!allChildrenSelected && selection.includes(row)) { if (!this.selectedItems.includes(row)) {
this.selectedItems.push(row);
}
} else if (!anyChildSelected && selection.includes(row)) {
this.$refs.table.toggleRowSelection(row, false); this.$refs.table.toggleRowSelection(row, false);
this.selectedItems = this.selectedItems.filter(
(item) => item.id !== row.id
);
} }
} }
}); });
console.log(this.selectedItems, "selectedItems");
this.updating = false;
}, },
handleSelect(selection, row) { handleSelect(selection, row) {
if (this.updating) return;
this.updating = true;
if (this.isRootNode(row)) { if (this.isRootNode(row)) {
row.billItemList.forEach((child) => { row.billItemList.forEach((child) => {
this.$refs.table.toggleRowSelection(child, row.isChecked); this.$refs.table.toggleRowSelection(child, selection.includes(row));
}); });
if (selection.includes(row)) {
row.billItemList.forEach((child) => {
if (!this.selectedItems.includes(child)) {
this.selectedItems.push(child);
}
});
if (!this.selectedItems.includes(row)) {
this.selectedItems.push(row);
}
} else {
this.selectedItems = this.selectedItems.filter(
(item) => !row.billItemList.includes(item) && item.id !== row.id
);
}
} else { } else {
const parentRow = this.findParentRow(this.productData, row); const parentRow = this.findParentRow(this.productData, row);
if (parentRow) { if (parentRow) {
const allChildrenSelected = parentRow.billItemList.every((child) => const allChildrenSelected = parentRow.billItemList.every((child) =>
selection.includes(child) selection.includes(child)
); );
this.$refs.table.toggleRowSelection(parentRow, allChildrenSelected); const anyChildSelected = parentRow.billItemList.some((child) =>
selection.includes(child)
);
if (allChildrenSelected) {
this.$refs.table.toggleRowSelection(parentRow, true);
if (!this.selectedItems.includes(parentRow)) {
this.selectedItems.push(parentRow);
}
} else if (!anyChildSelected) {
this.$refs.table.toggleRowSelection(parentRow, false);
this.selectedItems = this.selectedItems.filter(
(item) => item.id !== parentRow.id
);
}
} }
} }
},
handleSelectAll(selection) { console.log(this.selectedItems, "selectedItems");
this.productData.forEach((row) => { this.updating = false;
if (this.isRootNode(row)) {
row.billItemList.forEach((child) => {
this.$refs.table.toggleRowSelection(child, selection.includes(row));
});
}
});
}, },
findParentRow(productData, childRow) { findParentRow(productData, childRow) {
for (let row of productData) { for (let row of productData) {
@ -385,10 +414,6 @@ export default {
} }
return null; return null;
}, },
// handleMainListSelectionChange(val) {
// this.selectedItems = val;
// console.log(this.selectedItems, "this.selectedItems");
// },
isRootNode(row) { isRootNode(row) {
return row.billItemList; return row.billItemList;
}, },

View File

@ -9,7 +9,6 @@
:show-close="false" :show-close="false"
append-to-body append-to-body
align-center align-center
> >
<template #header="{ close, titleId, titleClass }"> <template #header="{ close, titleId, titleClass }">
<div class="my-header d-b-c"> <div class="my-header d-b-c">
@ -26,7 +25,7 @@
class="demo-form-inline" class="demo-form-inline"
> >
<el-row> <el-row>
<el-col :span="5"> <el-col :span="4">
<el-form-item label="业务日期"> <el-form-item label="业务日期">
<el-date-picker <el-date-picker
v-model="searchForm.businessTime" v-model="searchForm.businessTime"
@ -40,7 +39,11 @@
</el-col> </el-col>
<el-col :span="4"> <el-col :span="4">
<el-form-item label="供应商"> <el-form-item label="供应商">
<el-select v-model="searchForm.supplierId" placeholder="请选择"> <el-select
style="width: 100px"
v-model="searchForm.supplierId"
placeholder="请选择"
>
<el-option <el-option
v-for="(item, index) in supplierList" v-for="(item, index) in supplierList"
:key="index" :key="index"
@ -51,7 +54,11 @@
></el-col> ></el-col>
<el-col :span="4"> <el-col :span="4">
<el-form-item label="仓库"> <el-form-item label="仓库">
<el-select v-model="searchForm.depotId" placeholder="请选择"> <el-select
style="width: 100px"
v-model="searchForm.depotId"
placeholder="请选择"
>
<el-option <el-option
v-for="(item, index) in depotList" v-for="(item, index) in depotList"
:key="index" :key="index"
@ -62,7 +69,11 @@
></el-col> ></el-col>
<el-col :span="4"> <el-col :span="4">
<el-form-item label="业务员"> <el-form-item label="业务员">
<el-select v-model="searchForm.sales_id" placeholder="请选择"> <el-select
style="width: 100px"
v-model="searchForm.sales_id"
placeholder="请选择"
>
<el-option label="拣选货位" :value="0"></el-option> <el-option label="拣选货位" :value="0"></el-option>
<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>
@ -70,7 +81,11 @@
></el-col> ></el-col>
<el-col :span="4"> <el-col :span="4">
<el-form-item label="收货货位"> <el-form-item label="收货货位">
<el-select v-model="searchForm.sales_id" placeholder="请选择"> <el-select
style="width: 100px"
v-model="searchForm.sales_id"
placeholder="请选择"
>
<el-option label="拣选货位" :value="0"></el-option> <el-option label="拣选货位" :value="0"></el-option>
<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>
@ -118,7 +133,6 @@
style="width: 100%" style="width: 100%"
:tree-props="{ children: 'billItemList' }" :tree-props="{ children: 'billItemList' }"
@select="handleSelect" @select="handleSelect"
@select-all="handleSelectAll"
@selection-change="handleMainListSelectionChange" @selection-change="handleMainListSelectionChange"
v-loading="loading" v-loading="loading"
> >
@ -301,16 +315,9 @@ export default {
supplierList: [], supplierList: [],
selectedItems: [], selectedItems: [],
allData: {}, allData: {},
updating: false,
}; };
}, },
watch: {
parentSelected(newValue) {
//
if (!newValue && this.selectedItems.length > 0) {
this.cancelAllChildSelection();
}
},
},
props: ["open_procureAdd", "addForm", "businessType"], props: ["open_procureAdd", "addForm", "businessType"],
created() { created() {
this.dialogVisible = this.open_procureAdd; this.dialogVisible = this.open_procureAdd;
@ -322,54 +329,85 @@ export default {
} }
}, },
methods: { methods: {
cancelAllChildSelection() {
this.productData.forEach((row) => {
if (this.isRootNode(row)) {
row.billItemList.forEach((child) => {
this.$refs.table.toggleRowSelection(child, false);
});
}
});
},
handleMainListSelectionChange(selection) { handleMainListSelectionChange(selection) {
this.selectedItems = selection; if (this.updating) return;
console.log(this.selectedItems, "this.selectedItems "); this.updating = true;
this.selectedItems = [...selection];
console.log(selection, "selection");
this.productData.forEach((row) => { this.productData.forEach((row) => {
if (this.isRootNode(row)) { if (this.isRootNode(row)) {
const allChildrenSelected = row.billItemList.every((child) => const allChildrenSelected = row.billItemList.every((child) =>
selection.includes(child) selection.includes(child)
); );
if (allChildrenSelected && !selection.includes(row)) { const anyChildSelected = row.billItemList.some((child) =>
selection.includes(child)
);
if (anyChildSelected && !selection.includes(row)) {
this.$refs.table.toggleRowSelection(row, true); this.$refs.table.toggleRowSelection(row, true);
} else if (!allChildrenSelected && selection.includes(row)) { if (!this.selectedItems.includes(row)) {
this.selectedItems.push(row);
}
} else if (!anyChildSelected && selection.includes(row)) {
this.$refs.table.toggleRowSelection(row, false); this.$refs.table.toggleRowSelection(row, false);
this.selectedItems = this.selectedItems.filter(
(item) => item.id !== row.id
);
} }
} }
}); });
console.log(this.selectedItems, "selectedItems");
this.updating = false;
}, },
handleSelect(selection, row) { handleSelect(selection, row) {
if (this.updating) return;
this.updating = true;
if (this.isRootNode(row)) { if (this.isRootNode(row)) {
row.billItemList.forEach((child) => { row.billItemList.forEach((child) => {
this.$refs.table.toggleRowSelection(child, row.isChecked); this.$refs.table.toggleRowSelection(child, selection.includes(row));
}); });
if (selection.includes(row)) {
row.billItemList.forEach((child) => {
if (!this.selectedItems.includes(child)) {
this.selectedItems.push(child);
}
});
if (!this.selectedItems.includes(row)) {
this.selectedItems.push(row);
}
} else {
this.selectedItems = this.selectedItems.filter(
(item) => !row.billItemList.includes(item) && item.id !== row.id
);
}
} else { } else {
const parentRow = this.findParentRow(this.productData, row); const parentRow = this.findParentRow(this.productData, row);
if (parentRow) { if (parentRow) {
const allChildrenSelected = parentRow.billItemList.every((child) => const allChildrenSelected = parentRow.billItemList.every((child) =>
selection.includes(child) selection.includes(child)
); );
this.$refs.table.toggleRowSelection(parentRow, allChildrenSelected); const anyChildSelected = parentRow.billItemList.some((child) =>
selection.includes(child)
);
if (allChildrenSelected) {
this.$refs.table.toggleRowSelection(parentRow, true);
if (!this.selectedItems.includes(parentRow)) {
this.selectedItems.push(parentRow);
}
} else if (!anyChildSelected) {
this.$refs.table.toggleRowSelection(parentRow, false);
this.selectedItems = this.selectedItems.filter(
(item) => item.id !== parentRow.id
);
}
} }
} }
},
handleSelectAll(selection) { console.log(this.selectedItems, "selectedItems");
this.productData.forEach((row) => { this.updating = false;
if (this.isRootNode(row)) {
row.billItemList.forEach((child) => {
this.$refs.table.toggleRowSelection(child, selection.includes(row));
});
}
});
}, },
findParentRow(productData, childRow) { findParentRow(productData, childRow) {
for (let row of productData) { for (let row of productData) {
@ -385,12 +423,8 @@ export default {
} }
return null; return null;
}, },
// handleMainListSelectionChange(val) {
// this.selectedItems = val;
// console.log(this.selectedItems, "this.selectedItems");
// },
isRootNode(row) { isRootNode(row) {
return row.billItemList; return row.billItemList && row.billItemList.length > 0;
}, },
deleteImg(index) { deleteImg(index) {
this.searchForm.fileList.splice(index, 1); this.searchForm.fileList.splice(index, 1);

View File

@ -139,7 +139,6 @@
ref="table" ref="table"
:tree-props="{ children: 'billItemList' }" :tree-props="{ children: 'billItemList' }"
@select="handleSelect" @select="handleSelect"
@select-all="handleSelectAll"
@selection-change="handleSelectionChange" @selection-change="handleSelectionChange"
v-loading="loading" v-loading="loading"
> >
@ -322,12 +321,12 @@ export default {
}; };
}, },
watch: { watch: {
parentSelected(newValue) { // parentSelected(newValue) {
// // //
if (!newValue && this.selectedRows.length > 0) { // if (!newValue && this.selectedRows.length > 0) {
this.cancelAllChildSelection(); // this.cancelAllChildSelection();
} // }
}, // },
}, },
created() { created() {
/*获取列表*/ /*获取列表*/
@ -390,53 +389,85 @@ export default {
let Params = self.searchForm; let Params = self.searchForm;
self.getData(Params); self.getData(Params);
}, },
cancelAllChildSelection() {
this.tableData.forEach((row) => {
if (this.isRootNode(row)) {
row.billItemList.forEach((child) => {
this.$refs.table.toggleRowSelection(child, false);
});
}
});
},
handleSelectionChange(selection) { handleSelectionChange(selection) {
this.selectedRows = selection; if (this.updating) return;
this.updating = true;
this.selectedRows = [...selection];
console.log(selection, "selection");
this.tableData.forEach((row) => { this.tableData.forEach((row) => {
if (this.isRootNode(row)) { if (this.isRootNode(row)) {
const allChildrenSelected = row.billItemList.every((child) => const allChildrenSelected = row.billItemList.every((child) =>
selection.includes(child) selection.includes(child)
); );
if (allChildrenSelected && !selection.includes(row)) { const anyChildSelected = row.billItemList.some((child) =>
selection.includes(child)
);
if (anyChildSelected && !selection.includes(row)) {
this.$refs.table.toggleRowSelection(row, true); this.$refs.table.toggleRowSelection(row, true);
} else if (!allChildrenSelected && selection.includes(row)) { if (!this.selectedRows.includes(row)) {
this.selectedRows.push(row);
}
} else if (!anyChildSelected && selection.includes(row)) {
this.$refs.table.toggleRowSelection(row, false); this.$refs.table.toggleRowSelection(row, false);
this.selectedRows = this.selectedRows.filter(
(item) => item.id !== row.id
);
} }
} }
}); });
console.log(this.selectedRows, "selectedRows");
this.updating = false;
}, },
handleSelect(selection, row) { handleSelect(selection, row) {
if (this.updating) return;
this.updating = true;
if (this.isRootNode(row)) { if (this.isRootNode(row)) {
row.billItemList.forEach((child) => { row.billItemList.forEach((child) => {
this.$refs.table.toggleRowSelection(child, row.isChecked); this.$refs.table.toggleRowSelection(child, selection.includes(row));
}); });
if (selection.includes(row)) {
row.billItemList.forEach((child) => {
if (!this.selectedRows.includes(child)) {
this.selectedRows.push(child);
}
});
if (!this.selectedRows.includes(row)) {
this.selectedRows.push(row);
}
} else {
this.selectedRows = this.selectedRows.filter(
(item) => !row.billItemList.includes(item) && item.id !== row.id
);
}
} else { } else {
const parentRow = this.findParentRow(this.tableData, row); const parentRow = this.findParentRow(this.tableData, row);
if (parentRow) { if (parentRow) {
const allChildrenSelected = parentRow.billItemList.every((child) => const allChildrenSelected = parentRow.billItemList.every((child) =>
selection.includes(child) selection.includes(child)
); );
this.$refs.table.toggleRowSelection(parentRow, allChildrenSelected); const anyChildSelected = parentRow.billItemList.some((child) =>
selection.includes(child)
);
if (allChildrenSelected) {
this.$refs.table.toggleRowSelection(parentRow, true);
if (!this.selectedRows.includes(parentRow)) {
this.selectedRows.push(parentRow);
}
} else if (!anyChildSelected) {
this.$refs.table.toggleRowSelection(parentRow, false);
this.selectedRows = this.selectedRows.filter(
(item) => item.id !== parentRow.id
);
}
} }
} }
},
handleSelectAll(selection) { console.log(this.selectedRows, "selectedRows");
this.tableData.forEach((row) => { this.updating = false;
if (this.isRootNode(row)) {
row.billItemList.forEach((child) => {
this.$refs.table.toggleRowSelection(child, selection.includes(row));
});
}
});
}, },
findParentRow(tableData, childRow) { findParentRow(tableData, childRow) {
for (let row of tableData) { for (let row of tableData) {

View File

@ -6,7 +6,6 @@
:show-close="false" :show-close="false"
append-to-body append-to-body
align-center align-center
v-model="dialogVisible" v-model="dialogVisible"
@close="dialogFormVisible" @close="dialogFormVisible"
:close-on-click-modal="false" :close-on-click-modal="false"
@ -53,6 +52,9 @@
type="password" type="password"
></el-input> ></el-input>
</el-form-item> </el-form-item>
<el-form-item label="业务员" prop="isSuper">
<el-checkbox v-model="form.isSuper"></el-checkbox>
</el-form-item>
</el-form> </el-form>
<template #footer> <template #footer>
<div class="dialog-footer"> <div class="dialog-footer">

View File

@ -10,7 +10,6 @@
:show-close="false" :show-close="false"
append-to-body append-to-body
align-center align-center
> >
<template #header="{ close, titleId, titleClass }"> <template #header="{ close, titleId, titleClass }">
<div class="my-header d-b-c"> <div class="my-header d-b-c">
@ -54,6 +53,9 @@
type="password" type="password"
></el-input> ></el-input>
</el-form-item> </el-form-item>
<el-form-item label="业务员" prop="isSuper">
<el-checkbox v-model="form.isSuper"></el-checkbox>
</el-form-item>
</el-form> </el-form>
<template #footer> <template #footer>
<div class="dialog-footer"> <div class="dialog-footer">