diff --git a/src/views/repair/stockOperate/Components/SoIndex.vue b/src/views/repair/stockOperate/Components/SoIndex.vue
index 243ea99..9cee1b9 100644
--- a/src/views/repair/stockOperate/Components/SoIndex.vue
+++ b/src/views/repair/stockOperate/Components/SoIndex.vue
@@ -140,7 +140,7 @@
-
@@ -338,7 +338,9 @@ export default {
children: "children"
},
typeMap: null,
- selectRowIds: []
+ selectRowIds: [],
+ allSelectRows: [],
+ isRefresh: false,
}
},
mounted() {
@@ -350,11 +352,12 @@ export default {
Object.keys(this.$refs).forEach(key => {
if (key.startsWith('tableRef_')) {
const tableRef = this.$refs[key];
- if (tableRef[0]){
+ if (tableRef[0]) {
tableRef[0].clearSelection(); // 清除所有选择
this.inItems.forEach(([key, value]) => {
+ const ids = this.allSelectRows.map(item => item.id)
value.forEach(item => {
- if (this.selectRowIds.includes(item.id)) {
+ if (ids.includes(item.id)) {
tableRef[0].toggleRowSelection(item, true);
}
});
@@ -400,11 +403,13 @@ export default {
return JSON.parse(JSON.stringify(result))
},
searchByQuery() {
+ this.isRefresh = true
this.getSoiList().then(() => {
this.setSelectedRows()
})
},
resetByQuery() {
+ this.allSelectRows = []
this.inItemsQuery = null
this.searchByQuery()
},
@@ -481,6 +486,8 @@ export default {
},
// 入库操作
async handleInWares(row) {
+ this.allSelectRows = []
+ this.inItemsQuery = null
await this.listServer()
this.soId = row.id
this.inWaresFormData = {
@@ -510,16 +517,52 @@ export default {
this.inLoading = false
}
},
- selectRow(val) {
- this.selectRows = val
- if (val && val.length > 0) {
- this.selectRowIds = val.map(item => item.id)
+ selectRow(row) {
+ this.selectRows = row
+ this.selectRowIds = row.map(item => item.id)
+ if (row && row.length > 0) {
+ // 添加新的选择到 allSelectRows
+ this.allSelectRows = [...this.allSelectRows, ...row.filter(item => !this.allSelectRows.some(allRow => allRow.id === item.id))];
+ } else {
+ // 用户取消选择了所有的行
+ this.allSelectRows = this.allSelectRows.filter(item => !this.selectRowIds.includes(item.id));
}
+ // 更新自身的数据
+ // 点搜索不走下面逻辑
+ if (!this.isRefresh) {
+ // 如果本页没有选中数据,那就把属于本页的数据全部删掉
+ // tableRef可能有多个,全部取出来判断
+ const allRef = this.$refs
+ const newRef = Object.keys(allRef).filter(item => item.startsWith('tableRef_'))
+ newRef.forEach(tempRef => {
+ if (this.$refs[tempRef][0]) {
+ const ids = this.$refs[tempRef][0].data.map(item => item.id);
+ if (!row || row.length === 0) {
+ this.allSelectRows = this.allSelectRows.filter(item => !ids.includes(item.id))
+ } else {
+ // 把属于本页但是之前选中了本次没有选中的删掉
+ const rowIds = row.map(item => item.id)
+ const exIds = ids.filter(id => !rowIds.includes(id))
+ this.allSelectRows = this.allSelectRows.filter(item => !exIds.includes(item.id))
+ }
+ }
+ })
+ }
+ this.isRefresh = false
+ // 可能重复,去重
+ this.allSelectRows = this.allSelectRows.reduce((acc, item) => {
+ const flag = acc.find(i => i.id === item.id)
+ if (!flag) {
+ return acc.concat([item])
+ } else {
+ return acc
+ }
+ }, [])
},
async doInWares() {
try {
- this.inWaresFormData.soiList = this.selectRows
- this.inWaresFormData.waresList = this.selectRows.map(item => {
+ this.inWaresFormData.soiList = this.allSelectRows
+ this.inWaresFormData.waresList = this.allSelectRows.map(item => {
if (item.wares.ware){
item.wares.warehouse = item.wares.ware.id
}
diff --git a/src/views/repair/stockOperate/Components/WaresItem.vue b/src/views/repair/stockOperate/Components/WaresItem.vue
index 6d90c42..d74f988 100644
--- a/src/views/repair/stockOperate/Components/WaresItem.vue
+++ b/src/views/repair/stockOperate/Components/WaresItem.vue
@@ -95,14 +95,14 @@
@@ -307,6 +307,8 @@ export default {
children: "children"
},
typeMap: null,
+ allSelectRows: [],
+ isRefresh: false
}
},
mounted() {
@@ -346,6 +348,7 @@ export default {
return JSON.parse(JSON.stringify(result))
},
searchByQuery() {
+ this.isRefresh = true
const data = {
twId: this.twId,
query: this.query
@@ -357,14 +360,16 @@ export default {
setSelectedRows() {
this.$nextTick(() => {
this.$refs.tableRef.clearSelection(); // 清除所有选择
+ const ids = this.allSelectRows.map(item => item.id)
this.items.forEach(row => {
- if (this.selectionIds.includes(row.id)) {
+ if (ids.includes(row.id)) {
this.$refs.tableRef.toggleRowSelection(row, true); // 选中行
}
});
});
},
resetByQuery() {
+ this.allSelectRows = []
this.query = null
this.searchByQuery()
},
@@ -383,7 +388,7 @@ export default {
soStatus: this.type ? "04" : "07",
// purchaseType: "01"
}
- this.formData.repairSois = [...this.selections.map(item => {
+ this.formData.repairSois = [...this.allSelectRows.map(item => {
return {
soiType: this.type ? '02' : "04",
goodsId: item.waresId,
@@ -391,7 +396,7 @@ export default {
}
})]
if (this.type) {
- this.formData.items = [...this.selections.map(item => {
+ this.formData.items = [...this.allSelectRows.map(item => {
return {
id: item.id,
}
@@ -414,7 +419,7 @@ export default {
const brandRes = await getCarBrand(this.carInfo.carBrand)
this.carInfo.carBrand = brandRes.data.brandName
}
- const ids = this.selections.map(item => item.id)
+ const ids = this.allSelectRows.map(item => item.id)
const res = await getByIds(ids)
this.partList = Object.entries(res.data)
const values = this.partList.map(([key, value]) => value)
@@ -449,6 +454,8 @@ export default {
this.handleQuery()
},
handleDispose(row) {
+ this.allSelectRows = []
+ this.query = null
this.listServer()
this.formData = {}
this.formData = {
@@ -482,9 +489,33 @@ export default {
},
handleSelect(row) {
this.selections = row
- if (row && row.length > 0) {
- this.selectionIds = row.map(item => item.id);
+ this.selectionIds = row.map(item => item.id);
+ // 更新选择的数据
+ this.allSelectRows = [...this.allSelectRows, ...row]
+ // 更新自身的数据
+ // 点搜索不走下面逻辑
+ if (!this.isRefresh){
+ // 如果本页没有选中数据,那就把属于本页的数据全部删掉
+ const ids = this.$refs.tableRef.data.map(item => item.id);
+ if (!row || row.length === 0){
+ this.allSelectRows = this.allSelectRows.filter(item => !ids.includes(item.id))
+ }else {
+ // 把属于本页但是之前选中了本次没有选中的删掉
+ const rowIds = row.map(item => item.id)
+ const exIds = ids.filter(id => !rowIds.includes(id))
+ this.allSelectRows = this.allSelectRows.filter(item => !exIds.includes(item.id))
+ }
}
+ this.isRefresh = false
+ // 可能重复,去重
+ this.allSelectRows = this.allSelectRows.reduce((acc, item) => {
+ const flag = acc.find(i => i.id === item.id)
+ if (!flag){
+ return acc.concat([item])
+ }else {
+ return acc
+ }
+ }, [])
},
// 设置不统计的字段
getSummaries(param) {
@@ -591,12 +622,12 @@ export default {
// 提交
async handleSubmit() {
try {
- const isNull = this.validateNull();
- if (!isNull) return;
- const names = this.validateZero()
- if (names) {
- await this.$modal.confirm("确认配件:" + names + "的采购价格为0吗?")
- }
+ // const isNull = this.validateNull();
+ // if (!isNull) return;
+ // const names = this.validateZero()
+ // if (names) {
+ // await this.$modal.confirm("确认配件:" + names + "的采购价格为0吗?")
+ // }
await this.createInit()
await createRepairSo(this.formData)
this.inStockDialog = false