From 0e81cdea442c7984fedbe06e2d67a5807931aa4f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=B1=E8=80=98=E7=A8=B7?= <18026623439@163.com> Date: Tue, 8 Dec 2020 20:02:24 +0800 Subject: [PATCH] =?UTF-8?q?=E9=80=89=E6=8B=A9=E5=95=86=E5=93=81=E5=9B=9E?= =?UTF-8?q?=E6=98=BE=EF=BC=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/components/goods/index.vue | 53 +++++++++++++++++++++++++--- 1 file changed, 48 insertions(+), 5 deletions(-) diff --git a/src/views/components/goods/index.vue b/src/views/components/goods/index.vue index 9c30c81..c67c726 100644 --- a/src/views/components/goods/index.vue +++ b/src/views/components/goods/index.vue @@ -34,7 +34,7 @@ - + @@ -96,9 +96,41 @@ export default { } } }, + watch: { + page: function (val) { + var map = this.selectGoods; + map.set(this.lastPage, this.multipleSelection); + this.selectGoods = map; + + if (map.get(val)) { + this.multipleSelection = map.get(val); + } + this.lastPage = val; + }, + data: function (val) { + const _this=this; + _this.$nextTick(()=> { + //获取map + var map = this.selectGoods; + //判断当前页是否有数据 + var thePageData = map.get(this.page); + if (thePageData) { + thePageData.forEach(thePageData=>{ + val.forEach(tableData=>{ + if(tableData.id==thePageData.id){ + this.$refs.multipleTable.toggleRowSelection(tableData,true); + } + }) + }) + } + }) + } + }, data() { return { - newValue:this.value, + lastPage: 0, + selectGoods: new Map(), + newValue: this.value, delLoading: false, visible: false, queryTypeOptions: [ @@ -126,11 +158,20 @@ export default { }) }, doSelect() { - this.newValue = this.multipleSelection + this.newValue =[]; + var dataList=this.selectGoods; + dataList.forEach(i=>{ + i.forEach(j=>{ + this.newValue.push(j) + }) + }) this.$emit("selectGoods", this.newValue) this.dialog = false }, handleSelectionChange(val) { + var map = this.selectGoods; + map.set(this.lastPage, val); + this.selectGoods = map; this.multipleSelection = val; }, toSelete() { @@ -140,11 +181,13 @@ export default { beforeInit() { this.url = 'api/yxStoreProduct' const sort = 'id,desc' - this.params = { page: this.page, size: this.size, sort: sort, isShow: 1, isDel: 0 } + this.params = {page: this.page, size: this.size, sort: sort, isShow: 1, isDel: 0} const query = this.query const type = query.type const value = query.value - if (type && value) { this.params[type] = value } + if (type && value) { + this.params[type] = value + } return true } }