|
|
@ -154,6 +154,8 @@ |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
</template> |
|
|
|
</template> |
|
|
|
<script> |
|
|
|
<script> |
|
|
|
|
|
|
|
import { uuid } from 'vue-uuid' |
|
|
|
|
|
|
|
import { Loading } from 'element-ui' |
|
|
|
export default { |
|
|
|
export default { |
|
|
|
data() { |
|
|
|
data() { |
|
|
|
return { |
|
|
|
return { |
|
|
@ -179,8 +181,9 @@ export default { |
|
|
|
pageSize: 10, |
|
|
|
pageSize: 10, |
|
|
|
total: 0, |
|
|
|
total: 0, |
|
|
|
multipleSelection: [], |
|
|
|
multipleSelection: [], |
|
|
|
|
|
|
|
importLoading: null, |
|
|
|
|
|
|
|
tablePromises: [], |
|
|
|
importTypeList: [], |
|
|
|
importTypeList: [], |
|
|
|
importTypeIndex: 100000, |
|
|
|
|
|
|
|
fieldData: [], |
|
|
|
fieldData: [], |
|
|
|
fieldHead: [], |
|
|
|
fieldHead: [], |
|
|
|
tableName: '', |
|
|
|
tableName: '', |
|
|
@ -489,39 +492,45 @@ export default { |
|
|
|
}, |
|
|
|
}, |
|
|
|
// 查询分类下的表 |
|
|
|
// 查询分类下的表 |
|
|
|
getTable(n,isConcat){ |
|
|
|
getTable(n,isConcat){ |
|
|
|
this.$post(`${this.api.originalListById}?categoryId=${n.realId}&pageNum=${n.typeTreePage ? n.typeTreePage : 1}&pageSize=${this.typeTreeUnit}`).then(res => { |
|
|
|
this.tablePromises.push(new Promise((resolve,reject) => { |
|
|
|
let list = res.list.records |
|
|
|
this.$post(`${this.api.originalListById}?categoryId=${n.realId}&pageNum=${n.typeTreePage ? n.typeTreePage : 1}&pageSize=${this.typeTreeUnit}`).then(res => { |
|
|
|
list.map(n => { |
|
|
|
let list = res.list.records |
|
|
|
n.label = n.showName |
|
|
|
list.map(n => { |
|
|
|
n.id = String(n.id) |
|
|
|
n.label = n.showName |
|
|
|
// 已经存在的表,禁止再次勾选 |
|
|
|
n.id = String(n.id) |
|
|
|
if(this.defaultTypeChecked.includes(n.id)){ |
|
|
|
// 已经存在的表,禁止再次勾选 |
|
|
|
n.disabled = true |
|
|
|
if(this.defaultTypeChecked.includes(n.id)){ |
|
|
|
|
|
|
|
n.disabled = true |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
// 如果是懒加载,则拼接 |
|
|
|
|
|
|
|
if(isConcat){ |
|
|
|
|
|
|
|
n.children = n.children.concat(list) |
|
|
|
|
|
|
|
}else{ |
|
|
|
|
|
|
|
n.children = list |
|
|
|
|
|
|
|
n.tableLen = res.list.total |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
// 每次加载完,分页码数自动+1 |
|
|
|
|
|
|
|
n.typeTreePage++ |
|
|
|
|
|
|
|
resolve() |
|
|
|
|
|
|
|
}).catch(res => { |
|
|
|
|
|
|
|
reject() |
|
|
|
}) |
|
|
|
}) |
|
|
|
// 如果是懒加载,则拼接 |
|
|
|
})) |
|
|
|
if(isConcat){ |
|
|
|
|
|
|
|
n.children = n.children.concat(list) |
|
|
|
|
|
|
|
}else{ |
|
|
|
|
|
|
|
n.children = list |
|
|
|
|
|
|
|
n.tableLen = res.list.total |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
// 每次加载完,分页码数自动+1 |
|
|
|
|
|
|
|
n.typeTreePage++ |
|
|
|
|
|
|
|
}).catch(res => {}) |
|
|
|
|
|
|
|
}, |
|
|
|
}, |
|
|
|
// 导入数据 |
|
|
|
// 导入数据 |
|
|
|
batchImport(){ |
|
|
|
batchImport(){ |
|
|
|
|
|
|
|
this.importLoading = Loading.service({ |
|
|
|
|
|
|
|
background: 'rgba(255, 255, 255, .5)' |
|
|
|
|
|
|
|
}) |
|
|
|
// 这里查的是原始分类,跟其他任何地方查分类的接口都不一样,不要混淆,如果要改这个地方,要跟后端沟通 |
|
|
|
// 这里查的是原始分类,跟其他任何地方查分类的接口都不一样,不要混淆,如果要改这个地方,要跟后端沟通 |
|
|
|
this.$post(this.api.originalList).then(res => { |
|
|
|
this.$post(this.api.originalList).then(res => { |
|
|
|
const that = this |
|
|
|
|
|
|
|
// 处理id和label。因为这个树形要同时展示分类和表,所以name的key统一用label(分类和表的name的key不一样) |
|
|
|
// 处理id和label。因为这个树形要同时展示分类和表,所以name的key统一用label(分类和表的name的key不一样) |
|
|
|
function handleId(data){ |
|
|
|
function handleId(data){ |
|
|
|
data.map(n => { |
|
|
|
data.map(n => { |
|
|
|
that.importTypeIndex++ |
|
|
|
|
|
|
|
n.realId = n.id |
|
|
|
n.realId = n.id |
|
|
|
// 分类id跟表id可能会冲突,所以就加了个基数 |
|
|
|
// 分类id跟表id可能会冲突,所以加上uuid |
|
|
|
n.id = String(that.importTypeIndex + n.id) |
|
|
|
n.id = uuid.v4() |
|
|
|
n.label = n.categoryName |
|
|
|
n.label = n.categoryName |
|
|
|
if(n.children.length){ |
|
|
|
if(n.children.length){ |
|
|
|
handleId(n.children) |
|
|
|
handleId(n.children) |
|
|
@ -529,20 +538,19 @@ export default { |
|
|
|
}) |
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
|
handleId(res) |
|
|
|
handleId(res) |
|
|
|
// 查询表。pageSize传3000是防止选中的表在下面,查的太少的话无法选中分类,后续可根据需求修改 |
|
|
|
// 查询该分类下已勾选的表。pageSize传3000是防止查的表太少,无法选中分类,因为每个分类初始化的时候只查子下的20个表,后续可根据需求修改 |
|
|
|
this.$post(`${this.api.getIdQueryTable}?categoryId=${this.categoryId}&showName=${this.keyword}&pageNum=1&pageSize=3000&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 |
|
|
|
let list = res1.pageList.records |
|
|
|
this.defaultTypeChecked = list.map(n => n.copyId) // copyId为原始表id,通过这个id才能选中表 |
|
|
|
this.defaultTypeChecked = list.map(n => n.copyId) // copyId为原始表id,通过这个id才能选中表 |
|
|
|
const that = this |
|
|
|
|
|
|
|
// 递归处理分页 |
|
|
|
// 递归处理分页 |
|
|
|
function handleId(data){ |
|
|
|
const handleId = data => { |
|
|
|
data.map(n => { |
|
|
|
data.map(n => { |
|
|
|
if(n.children.length){ |
|
|
|
if(n.children.length){ |
|
|
|
handleId(n.children) |
|
|
|
handleId(n.children) |
|
|
|
}else{ |
|
|
|
}else{ |
|
|
|
// 默认分页码数为1 |
|
|
|
// 默认分页码数为1 |
|
|
|
n.typeTreePage = 1 |
|
|
|
n.typeTreePage = 1 |
|
|
|
that.getTable(n) |
|
|
|
this.getTable(n) |
|
|
|
} |
|
|
|
} |
|
|
|
}) |
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
@ -556,14 +564,20 @@ export default { |
|
|
|
} |
|
|
|
} |
|
|
|
}) |
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
|
setTimeout(() => { |
|
|
|
Promise.all(this.tablePromises).then(_ => { |
|
|
|
handleDisabled(res) |
|
|
|
handleDisabled(res) |
|
|
|
this.importTypeList = res |
|
|
|
this.importTypeList = res |
|
|
|
},500) |
|
|
|
this.importLoading.close() |
|
|
|
}).catch(res => {}) |
|
|
|
this.importVisible = true |
|
|
|
|
|
|
|
console.log('全部分类:', res) |
|
|
|
this.importVisible = true |
|
|
|
console.log('该分类下已选的表id:', this.defaultTypeChecked) |
|
|
|
}).catch(res => {}) |
|
|
|
}) |
|
|
|
|
|
|
|
}).catch(res => { |
|
|
|
|
|
|
|
this.importLoading.close() |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
}).catch(res => { |
|
|
|
|
|
|
|
this.importLoading.close() |
|
|
|
|
|
|
|
}) |
|
|
|
}, |
|
|
|
}, |
|
|
|
// 查询表的字段 |
|
|
|
// 查询表的字段 |
|
|
|
getFields(){ |
|
|
|
getFields(){ |
|
|
|