From a10c817516f0efb717ff4271d8f84793cf6e9190 Mon Sep 17 00:00:00 2001 From: yujialong <479214531@qq.com> Date: Thu, 25 Nov 2021 09:14:27 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E6=95=B0=E6=8D=AE=E6=96=B0=E5=A2=9E?= =?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 | 82 +++++++++++++++++++++++++----------- 1 file changed, 58 insertions(+), 24 deletions(-) diff --git a/src/views/data/Framework.vue b/src/views/data/Framework.vue index a60879e..7299174 100644 --- a/src/views/data/Framework.vue +++ b/src/views/data/Framework.vue @@ -77,7 +77,7 @@ :default-checked-keys="defaultTypeChecked" :current-node-key="curId" show-checkbox - :props="defaultProps" + :props="defaultPropsImport" highlight-current @node-click="importTypeClick" @node-expand="importTypeExpand" @@ -160,6 +160,10 @@ export default { children: 'children', label: 'categoryName' }, + defaultPropsImport: { + children: 'children', + label: 'label' + }, defaultActive: [], added: false, typeVisible: false, @@ -258,10 +262,13 @@ export default { this.getData() }, addType(row){ - this.categoryId = row.data.id - if (row) this.defaultActive = [row.data.id] + if (row) { + this.categoryId = row.data.id + this.defaultActive = [row.data.id] + } this.typeVisible = true this.levelId = row ? row.data.id : 0 + }, editType(row){ this.typeVisible = true @@ -309,9 +316,17 @@ export default { }).then(res => { this.$message.success('添加成功') this.getType(this.node, this.resolve) - let node = this.$refs.type.getNode(this.categoryId) - node.loaded = false - node.expand() + if (this.levelId) { + let node = this.$refs.type.getNode(this.categoryId) + node.loaded = false + node.expand() + } else { + // this.categoryId = '' + // this.defaultProps = [] + // this.$refs.type.setCurrentNode(0) + // this.getType(0, this.resolve) + location.reload() + } this.typeVisible = false setTimeout(() => { this.submited = false @@ -578,33 +593,52 @@ export default { if(!checked.length) return this.$message.warning('请选择数据') this.submited = true const typeIds = checked.filter(e => !e.name).map(e => e.realId) // 先筛选出分类id,再获取分类真正的id - this.getNames(typeIds).then(() => { - const data = this.names - const dataList = [] - for (let i = 0, len = data.length; i < len; i += 2000) { - 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() - }) - })) + const tableIds = checked.filter(e => e.name) + const categoryId = Number(this.categoryId) + tableIds.map(e => { + delete e.id + e.categoryId = categoryId + }) + if (typeIds.length) { + this.getNames(typeIds).then(() => { + const data = this.names + const dataList = [] + for (let i = 0, len = data.length; i < len; i += 2000) { + 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() + }) + })) + }) + Promise.all(promiseList).then(res => { + this.$message.success('导入成功') + this.getData() + this.importVisible = false + setTimeout(() => { + this.submited = false + },1000) + }).catch(err => { + this.submited = false + }) }) - Promise.all(promiseList).then(res => { + } else { + this.$post(this.api.saveTable, tableIds).then(res => { this.$message.success('导入成功') this.getData() this.importVisible = false setTimeout(() => { this.submited = false },1000) - }).catch(err => { + }).catch(res => { this.submited = false }) - }) + } } } }; From 0748a8ba1e1104267a115749babdd0b6b3247587 Mon Sep 17 00:00:00 2001 From: Jo <479214531@qq.com> Date: Fri, 26 Nov 2021 00:46:23 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E4=BA=A7=E5=93=81?= =?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/Product.vue | 166 ++++++++++++++++--------------------- 1 file changed, 71 insertions(+), 95 deletions(-) diff --git a/src/views/data/Product.vue b/src/views/data/Product.vue index d9cd532..a0fa86b 100644 --- a/src/views/data/Product.vue +++ b/src/views/data/Product.vue @@ -82,7 +82,7 @@ 配置数据权限 -