diff --git a/src/utils/api.js b/src/utils/api.js index 761f3aa..9783b3a 100644 --- a/src/utils/api.js +++ b/src/utils/api.js @@ -164,6 +164,7 @@ export default { editTableName: `${host}/data/data/table/editTableName`, updateTableCommit: `${host}/data/data/updateTableCommit`, getLevel: `${host}/data/category/getLevel`, + getAllTableInfoByCategoryId: `${host}/data/data/product/getAllTableInfoByCategoryId`, // 产品管理 deleteProduct: `${host}/data/data/product/delete`, diff --git a/src/views/data/Framework.vue b/src/views/data/Framework.vue index 9dff693..930e3e3 100644 --- a/src/views/data/Framework.vue +++ b/src/views/data/Framework.vue @@ -70,8 +70,7 @@
{ that.importTypeIndex++ n.realId = n.id - // 分类id跟表id可能是冲突,所以就加了个基数,后续再优化 + // 分类id跟表id可能会冲突,所以就加了个基数 n.id = String(that.importTypeIndex + n.id) n.label = n.categoryName if(n.children.length){ @@ -495,7 +493,7 @@ export default { }) } handleId(res) - this.$post(`${this.api.getIdQueryTable}?categoryId=${this.categoryId}&showName=${this.keyword}&pageNum=1&pageSize=10000&updateTime=${this.updateTime ? this.updateTime : ''}`).then(res1 => { + this.$post(`${this.api.getIdQueryTable}?categoryId=${this.categoryId}&showName=${this.keyword}&pageNum=1&pageSize=3000&updateTime=${this.updateTime ? this.updateTime : ''}`).then(res1 => { let list = res1.pageList.records this.defaultTypeChecked = list.map(n => n.copyId) const that = this @@ -556,63 +554,31 @@ export default { closeImport(){ this.$refs.typeTree.setCheckedKeys([]) this.names = [] - this.showNames = [] }, // 获取names和showNames,提交的时候需要 - getNames(){ - // 获取已经勾选的分类 - let list = this.$refs.typeTree.getCheckedNodes() + getNames(list){ + const categoryId = Number(this.categoryId) return new Promise((resolve,reject) => { - let getLen = 0 - list.map(n => { - // 如果tableLen大于子级的数量,则表示这个分类下的子级是没有全部加载出来的,要在下面去查询出来,这里先记载要查询的分类数量 - if(n.tableLen && n.tableLen > n.children.length) getLen++ - }) - list.map((n,i) => { - if(n.tableLen && n.tableLen > n.children.length){ - // pageSize传10000是要查询全部表,后续如果数据多了,则按需调整 - this.$post(`${this.api.originalListById}?categoryId=${n.realId}&pageNum=1&pageSize=10000`).then(res => { - let tableList = res.list.records - // 查询完1个,则数量-1 - getLen-- - tableList.map(n => { - // 如果是默认没有的表,则添加进去 - if(!this.defaultTypeChecked.includes(String(n.id))){ - this.names.push(n.name) - this.showNames.push(n.showName) - } - }) - // 清0后,才执行resolve - if(!getLen) resolve() - }).catch(res => {}) - }else if(n.name && !n.disabled && !this.names.includes(n.name)){ // 如果是表,并且不是存在于分类下了的表,并且没重复,则添加进去 - this.names.push(n.name) - this.showNames.push(n.showName) - if(!getLen) resolve() - } - }) + // 根据选择的分类id查询下面的表id + this.$get(`${this.api.getAllTableInfoByCategoryId}?categoryId=${list.join()}`).then(res => { + const list = res.tableInfo + list.map(e => { + delete e.id + e.categoryId = categoryId + }) + this.names = list + resolve() + }).catch(res => {}) }) }, confirmImport(){ if(this.submited) return false + const checked = this.$refs.typeTree.getCheckedNodes() // 勾选的数据 // 如果没有选择任何数据 - if(!this.$refs.typeTree.getCheckedNodes().length) return this.$message.warning('请选择数据') - this.getNames().then(() => { - let names = Array.from(new Set(this.names)) - let showNames = Array.from(new Set(this.showNames)) - if(!names.length) return this.$message.warning('请选择数据') - - this.submited = true - let data = [] - let categoryId = Number(this.categoryId) - names.map((n,i) => { - data.push({ - categoryId, - name: n, - showName: showNames[i], - }) - }) - this.$post(this.api.saveTable,data).then(res => { + if(!checked.length) return this.$message.warning('请选择数据') + const typeIds = checked.filter(e => !e.name).map(e => e.realId) // 先筛选出分类id,再获取分类真正的id + this.getNames(typeIds).then(() => { + this.$post(this.api.saveTable, this.names).then(res => { this.$message.success('导入成功') this.getData() this.importVisible = false @@ -623,7 +589,7 @@ export default { this.submited = false }) }) - }, + } } }; diff --git a/src/views/data/Product.vue b/src/views/data/Product.vue index 7aef0fc..d9cd532 100644 --- a/src/views/data/Product.vue +++ b/src/views/data/Product.vue @@ -82,7 +82,6 @@ 配置数据权限 -