From 13b26d6c13362bd304d2a3abe1fd7e5b5951813c Mon Sep 17 00:00:00 2001 From: Jo <479214531@qq.com> Date: Sat, 27 Nov 2021 00:39:16 +0800 Subject: [PATCH 1/5] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/data/Framework.vue | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/views/data/Framework.vue b/src/views/data/Framework.vue index a984f0f..657d30d 100644 --- a/src/views/data/Framework.vue +++ b/src/views/data/Framework.vue @@ -194,7 +194,7 @@ export default { previewData: [], curComment: [], submited: false, - names: [], + categorys: [], nameVisible: false, curRow: {}, headVisible: false, @@ -563,7 +563,7 @@ export default { }, closeImport(){ this.$refs.typeTree.setCheckedKeys([]) - this.names = [] + this.categorys = [] }, // 获取names和showNames,提交的时候需要 getNames(list){ @@ -576,7 +576,7 @@ export default { delete e.id e.categoryId = categoryId }) - this.names = list + this.categorys = list resolve() }).catch(res => {}) }) @@ -594,9 +594,14 @@ export default { delete e.id e.categoryId = categoryId }) + function uniq (arr, val) { + const res = new Map() + return arr.filter(e => !res.has(e[val]) && res.set(e[val], 1)) + } if (typeIds.length) { this.getNames(typeIds).then(() => { - const data = this.names + const allIds = [...this.categorys, ...tableIds] + const data = uniq(allIds, 'name') const dataList = [] for (let i = 0, len = data.length; i < len; i += 2000) { dataList.push(data.slice(i, i + 2000)) From 12b6070cb4301aa09dd46f314fbeddf76ba79539 Mon Sep 17 00:00:00 2001 From: Jo <479214531@qq.com> Date: Sat, 27 Nov 2021 01:44:38 +0800 Subject: [PATCH 2/5] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/data/Framework.vue | 78 +++++++++++++++++++++++++++--------- 1 file changed, 60 insertions(+), 18 deletions(-) diff --git a/src/views/data/Framework.vue b/src/views/data/Framework.vue index 657d30d..4fffddd 100644 --- a/src/views/data/Framework.vue +++ b/src/views/data/Framework.vue @@ -519,7 +519,16 @@ export default { }) } handleId(res) + function handleDisabled (list) { + list.map(e => { + if (e.children && e.children.length) { + if (e.children.every(e => e.disabled)) e.disabled = true + handleDisabled(e.children) + } + }) + } setTimeout(() => { + handleDisabled(res) this.importTypeList = res },500) }).catch(res => {}) @@ -581,9 +590,17 @@ export default { }).catch(res => {}) }) }, + saveSuccess() { + this.$message.success('导入成功') + this.getData() + this.importVisible = false + setTimeout(() => { + this.submited = false + },1000) + }, confirmImport(){ if(this.submited) return false - const checked = this.$refs.typeTree.getCheckedNodes() // 勾选的数据 + const checked = this.$refs.typeTree.getCheckedNodes().filter(e => !e.disabled) // 勾选的数据 // 如果没有选择任何数据 if(!checked.length) return this.$message.warning('请选择数据') this.submited = true @@ -607,25 +624,50 @@ export default { dataList.push(data.slice(i, i + 2000)) } const promiseList = [] - dataList.map(e => { - promiseList.push(new Promise((resolve,reject) => { - this.$post(this.api.saveTable, e).then(res => { - resolve() - }).catch(res => { - reject() + if (dataList.length > 6) { + dataList.slice(0, 6).map(e => { + promiseList.push(new Promise((resolve,reject) => { + this.$post(this.api.saveTable, e).then(res => { + resolve() + }).catch(res => { + reject() + }) + })) + }) + Promise.all(promiseList).then(res => { + dataList.slice(6).map(e => { + promiseList.push(new Promise((resolve,reject) => { + this.$post(this.api.saveTable, e).then(res => { + resolve() + }).catch(res => { + reject() + }) + })) }) - })) - }) - Promise.all(promiseList).then(res => { - this.$message.success('导入成功') - this.getData() - this.importVisible = false - setTimeout(() => { + Promise.all(promiseList).then(res => { + this.saveSuccess() + }).catch(err => { + this.submited = false + }) + }).catch(err => { this.submited = false - },1000) - }).catch(err => { - this.submited = false - }) + }) + } else { + dataList.map(e => { + promiseList.push(new Promise((resolve,reject) => { + this.$post(this.api.saveTable, e).then(res => { + resolve() + }).catch(res => { + reject() + }) + })) + }) + Promise.all(promiseList).then(res => { + this.saveSuccess() + }).catch(err => { + this.submited = false + }) + } }) } else { this.$post(this.api.saveTable, tableIds).then(res => { From 98e5a64b4ae7a66832448f13fb5f63d93a3751f2 Mon Sep 17 00:00:00 2001 From: yujialong <479214531@qq.com> Date: Tue, 30 Nov 2021 11:43:29 +0800 Subject: [PATCH 3/5] =?UTF-8?q?=E6=95=B0=E6=8D=AE=E5=AF=BC=E5=85=A5?= =?UTF-8?q?=E6=B3=A8=E9=87=8A=E5=AE=8C=E5=96=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/data/Framework.vue | 120 +++++++++++++++++++++++------------ 1 file changed, 80 insertions(+), 40 deletions(-) diff --git a/src/views/data/Framework.vue b/src/views/data/Framework.vue index 4fffddd..b2ad4ee 100644 --- a/src/views/data/Framework.vue +++ b/src/views/data/Framework.vue @@ -1,6 +1,7 @@