|
|
@ -9,7 +9,7 @@ |
|
|
|
<span class="custom-tree-node" slot-scope="{ node, data }"> |
|
|
|
<span class="custom-tree-node" slot-scope="{ node, data }"> |
|
|
|
<span :title="node.label">{{ node.label }}</span> |
|
|
|
<span :title="node.label">{{ node.label }}</span> |
|
|
|
<span class="actions"> |
|
|
|
<span class="actions"> |
|
|
|
<i v-if="!data.isThird" class="el-icon-circle-plus-outline" @click.stop="addType(node)"></i> |
|
|
|
<i v-if="data.level != 3" class="el-icon-circle-plus-outline" @click.stop="addType(node)"></i> |
|
|
|
<i class="el-icon-edit" @click.stop="editType(node)"></i> |
|
|
|
<i class="el-icon-edit" @click.stop="editType(node)"></i> |
|
|
|
<i class="el-icon-delete" @click.stop="delType(node)"></i> |
|
|
|
<i class="el-icon-delete" @click.stop="delType(node)"></i> |
|
|
|
</span> |
|
|
|
</span> |
|
|
@ -156,19 +156,19 @@ export default { |
|
|
|
methods: { |
|
|
|
methods: { |
|
|
|
getType(){ |
|
|
|
getType(){ |
|
|
|
this.$post(this.api.getTableByClassification).then(res => { |
|
|
|
this.$post(this.api.getTableByClassification).then(res => { |
|
|
|
res.map(n => { |
|
|
|
// 递归赋值,同时添加层级标识 |
|
|
|
n.id = String(n.id) |
|
|
|
function handleId(data,level = 0){ |
|
|
|
n.label = n.categoryName |
|
|
|
data.map(n => { |
|
|
|
n.children.map(n => { |
|
|
|
|
|
|
|
n.id = String(n.id) |
|
|
|
|
|
|
|
n.label = n.categoryName |
|
|
|
|
|
|
|
n.children.map(n => { |
|
|
|
|
|
|
|
n.id = String(n.id) |
|
|
|
n.id = String(n.id) |
|
|
|
n.label = n.categoryName |
|
|
|
n.label = n.categoryName |
|
|
|
n.isThird = true |
|
|
|
n.level = level + 1 |
|
|
|
}) |
|
|
|
if(n.children.length){ |
|
|
|
}) |
|
|
|
handleId(n.children,n.level) |
|
|
|
|
|
|
|
} |
|
|
|
}) |
|
|
|
}) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
handleId(res) |
|
|
|
|
|
|
|
|
|
|
|
this.typeList = res |
|
|
|
this.typeList = res |
|
|
|
if(res[0].children.length){ |
|
|
|
if(res[0].children.length){ |
|
|
|
this.categoryId = res[0].children[0].id |
|
|
|
this.categoryId = res[0].children[0].id |
|
|
@ -177,6 +177,7 @@ export default { |
|
|
|
this.categoryId = res[0].id |
|
|
|
this.categoryId = res[0].id |
|
|
|
this.defaultActive = [res[0].id] |
|
|
|
this.defaultActive = [res[0].id] |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
// 取第一个分类的id |
|
|
|
this.$nextTick(() => { |
|
|
|
this.$nextTick(() => { |
|
|
|
this.$refs.type.setCurrentKey(res[0].children[0].id) |
|
|
|
this.$refs.type.setCurrentKey(res[0].children[0].id) |
|
|
|
}) |
|
|
|
}) |
|
|
@ -267,6 +268,7 @@ export default { |
|
|
|
let data = res.data |
|
|
|
let data = res.data |
|
|
|
data.map(n => { |
|
|
|
data.map(n => { |
|
|
|
for(let i in n){ |
|
|
|
for(let i in n){ |
|
|
|
|
|
|
|
// 如果是以+0000结尾的,就表明这个是时间,则转化为正常的时间格式 |
|
|
|
if(typeof n[i] == 'string' && n[i].endsWith('+0000')) n[i] = this.formatDate('yyyy-MM-dd hh:mm:ss',new Date(n[i])) |
|
|
|
if(typeof n[i] == 'string' && n[i].endsWith('+0000')) n[i] = this.formatDate('yyyy-MM-dd hh:mm:ss',new Date(n[i])) |
|
|
|
} |
|
|
|
} |
|
|
|
}) |
|
|
|
}) |
|
|
@ -310,6 +312,7 @@ export default { |
|
|
|
this.$message.error('请先选择数据') |
|
|
|
this.$message.error('请先选择数据') |
|
|
|
} |
|
|
|
} |
|
|
|
}, |
|
|
|
}, |
|
|
|
|
|
|
|
// 递归查询当前展开的分类下的子分类 |
|
|
|
getMoreTable(list,id){ |
|
|
|
getMoreTable(list,id){ |
|
|
|
list.map(n => { |
|
|
|
list.map(n => { |
|
|
|
if(n.id == id){ |
|
|
|
if(n.id == id){ |
|
|
@ -319,82 +322,91 @@ export default { |
|
|
|
} |
|
|
|
} |
|
|
|
}) |
|
|
|
}) |
|
|
|
}, |
|
|
|
}, |
|
|
|
|
|
|
|
// 懒加载后新加载出来的数据可能是之前就存在于这个分类下了的,因此是要自动勾选的,所以在这里去拿这个分类下已经存在了的表的id去做一个重新勾选 |
|
|
|
|
|
|
|
renderChecked(){ |
|
|
|
|
|
|
|
let result = [] |
|
|
|
|
|
|
|
let list = this.$refs.typeTree.getCheckedNodes() |
|
|
|
|
|
|
|
list.map((n,i) => { |
|
|
|
|
|
|
|
if(n.tableLen && n.tableLen > n.children.length){ |
|
|
|
|
|
|
|
result = [...result,...n.children.map(n => n.id)] |
|
|
|
|
|
|
|
}else{ |
|
|
|
|
|
|
|
result.push(n.id) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
this.$refs.typeTree.setCheckedKeys(result) |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
// 因为数据会有上万条的情况,一次加载出来dom太多了,所以用懒加载去处理 |
|
|
|
loadType(e){ |
|
|
|
loadType(e){ |
|
|
|
clearTimeout(this.typeTimer) |
|
|
|
clearTimeout(this.typeTimer) |
|
|
|
let typeTree = this.$refs.typeTreeWrap |
|
|
|
let typeTree = this.$refs.typeTreeWrap |
|
|
|
this.typeTimer = setTimeout(() => { |
|
|
|
this.typeTimer = setTimeout(() => { |
|
|
|
this.typeTreeScrollTop = typeTree.scrollTop - this.typeTreeScrollTop |
|
|
|
this.typeTreeScrollTop = typeTree.scrollTop - this.typeTreeScrollTop |
|
|
|
|
|
|
|
// 如果已经滚动到底部,则加载下面的数据 |
|
|
|
if(this.typeTreeScrollTop > 0 && typeTree.clientHeight + typeTree.scrollTop == typeTree.scrollHeight){ |
|
|
|
if(this.typeTreeScrollTop > 0 && typeTree.clientHeight + typeTree.scrollTop == typeTree.scrollHeight){ |
|
|
|
this.getMoreTable(this.importTypeList,this.curExpand) |
|
|
|
this.getMoreTable(this.importTypeList,this.curExpand) |
|
|
|
setTimeout(() => { |
|
|
|
setTimeout(() => { |
|
|
|
this.$nextTick(() => { |
|
|
|
this.$nextTick(() => { |
|
|
|
this.$refs.typeTree.setCheckedKeys(this.defaultTypeChecked) |
|
|
|
this.renderChecked() |
|
|
|
}) |
|
|
|
}) |
|
|
|
},300) |
|
|
|
},300) |
|
|
|
} |
|
|
|
} |
|
|
|
},50) |
|
|
|
},50) |
|
|
|
}, |
|
|
|
}, |
|
|
|
|
|
|
|
// 查询分类下的表 |
|
|
|
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.$post(`${this.api.originalListById}?categoryId=${n.realId}&pageNum=${n.typeTreePage ? n.typeTreePage : 1}&pageSize=${this.typeTreeUnit}`).then(res => { |
|
|
|
let list = res.list.records |
|
|
|
let list = res.list.records |
|
|
|
list.map(n => { |
|
|
|
list.map(n => { |
|
|
|
n.label = n.showName |
|
|
|
n.label = n.showName |
|
|
|
n.id = String(n.id) |
|
|
|
n.id = String(n.id) |
|
|
|
|
|
|
|
// 已经存在的表,禁止再次勾选 |
|
|
|
if(this.defaultTypeChecked.includes(n.id)){ |
|
|
|
if(this.defaultTypeChecked.includes(n.id)){ |
|
|
|
n.disabled = true |
|
|
|
n.disabled = true |
|
|
|
} |
|
|
|
} |
|
|
|
}) |
|
|
|
}) |
|
|
|
|
|
|
|
// 如果是懒加载,则拼接 |
|
|
|
if(isConcat){ |
|
|
|
if(isConcat){ |
|
|
|
n.children = n.children.concat(list) |
|
|
|
n.children = n.children.concat(list) |
|
|
|
}else{ |
|
|
|
}else{ |
|
|
|
n.children = list |
|
|
|
n.children = list |
|
|
|
n.tableLen = res.list.total |
|
|
|
n.tableLen = res.list.total |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
// 每次加载完,分页码数自动+1 |
|
|
|
n.typeTreePage++ |
|
|
|
n.typeTreePage++ |
|
|
|
}).catch(res => {}) |
|
|
|
}).catch(res => {}) |
|
|
|
}, |
|
|
|
}, |
|
|
|
batchImport(){ |
|
|
|
batchImport(){ |
|
|
|
this.$post(this.api.originalList).then(res => { |
|
|
|
this.$post(this.api.originalList).then(res => { |
|
|
|
res.map(n => { |
|
|
|
const that = this |
|
|
|
this.importTypeIndex++ |
|
|
|
function handleId(data){ |
|
|
|
n.realId = n.id |
|
|
|
data.map(n => { |
|
|
|
n.id = String(this.importTypeIndex + n.id) |
|
|
|
that.importTypeIndex++ |
|
|
|
n.label = n.categoryName |
|
|
|
|
|
|
|
n.children.map(n => { |
|
|
|
|
|
|
|
n.realId = n.id |
|
|
|
|
|
|
|
this.importTypeIndex++ |
|
|
|
|
|
|
|
n.id = String(this.importTypeIndex + n.id) |
|
|
|
|
|
|
|
n.label = n.categoryName |
|
|
|
|
|
|
|
n.children.map(n => { |
|
|
|
|
|
|
|
this.importTypeIndex++ |
|
|
|
|
|
|
|
n.realId = n.id |
|
|
|
n.realId = n.id |
|
|
|
n.id = String(this.importTypeIndex + n.id) |
|
|
|
// 分类id跟表id可能是冲突,所以就加了个基数,后续再优化 |
|
|
|
|
|
|
|
n.id = String(that.importTypeIndex + n.id) |
|
|
|
n.label = n.categoryName |
|
|
|
n.label = n.categoryName |
|
|
|
n.isThird = true |
|
|
|
if(n.children.length){ |
|
|
|
}) |
|
|
|
handleId(n.children) |
|
|
|
}) |
|
|
|
} |
|
|
|
}) |
|
|
|
}) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
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=10000&updateTime=${this.updateTime ? this.updateTime : ''}`).then(res1 => { |
|
|
|
let list = res1.pageList.records |
|
|
|
let list = res1.pageList.records |
|
|
|
this.defaultTypeChecked = list.map(n => n.copyId) |
|
|
|
this.defaultTypeChecked = list.map(n => n.copyId) |
|
|
|
res.map((n,i) => { |
|
|
|
const that = this |
|
|
|
if(n.children.length){ |
|
|
|
function handleId(data){ |
|
|
|
n.children.map(n => { |
|
|
|
data.map(n => { |
|
|
|
if(n.children.length){ |
|
|
|
if(n.children.length){ |
|
|
|
n.children.map(n => { |
|
|
|
handleId(n.children) |
|
|
|
n.typeTreePage = 1 |
|
|
|
|
|
|
|
this.getTable(n) |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
}else{ |
|
|
|
}else{ |
|
|
|
|
|
|
|
// 默认分页码数为1 |
|
|
|
n.typeTreePage = 1 |
|
|
|
n.typeTreePage = 1 |
|
|
|
this.getTable(n) |
|
|
|
that.getTable(n) |
|
|
|
} |
|
|
|
} |
|
|
|
}) |
|
|
|
}) |
|
|
|
}else{ |
|
|
|
|
|
|
|
n.typeTreePage = 1 |
|
|
|
|
|
|
|
this.getTable(n) |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
}) |
|
|
|
handleId(res) |
|
|
|
setTimeout(() => { |
|
|
|
setTimeout(() => { |
|
|
|
this.importTypeList = res |
|
|
|
this.importTypeList = res |
|
|
|
},500) |
|
|
|
},500) |
|
|
@ -407,6 +419,7 @@ export default { |
|
|
|
this.$get(`${this.api.staticPreview}?tableName=${this.tableName}`).then(res => { |
|
|
|
this.$get(`${this.api.staticPreview}?tableName=${this.tableName}`).then(res => { |
|
|
|
let comment = res.comment |
|
|
|
let comment = res.comment |
|
|
|
let fieldHead = [] |
|
|
|
let fieldHead = [] |
|
|
|
|
|
|
|
// id和操作时间这两个字段不用展示 |
|
|
|
comment.map(n => { |
|
|
|
comment.map(n => { |
|
|
|
n.field != 'id' && n.field != 'operation_time' && fieldHead.push(n) |
|
|
|
n.field != 'id' && n.field != 'operation_time' && fieldHead.push(n) |
|
|
|
}) |
|
|
|
}) |
|
|
@ -415,6 +428,7 @@ export default { |
|
|
|
let data = res.data |
|
|
|
let data = res.data |
|
|
|
data.map(n => { |
|
|
|
data.map(n => { |
|
|
|
for(let i in n){ |
|
|
|
for(let i in n){ |
|
|
|
|
|
|
|
// 如果是以+0000结尾的,就表明这个是时间,则转化为正常的时间格式 |
|
|
|
if(typeof n[i] == 'string' && n[i].endsWith('+0000')) n[i] = this.formatDate('yyyy-MM-dd hh:mm:ss',new Date(n[i])) |
|
|
|
if(typeof n[i] == 'string' && n[i].endsWith('+0000')) n[i] = this.formatDate('yyyy-MM-dd hh:mm:ss',new Date(n[i])) |
|
|
|
} |
|
|
|
} |
|
|
|
}) |
|
|
|
}) |
|
|
@ -423,42 +437,51 @@ export default { |
|
|
|
this.importVisible = true |
|
|
|
this.importVisible = true |
|
|
|
}, |
|
|
|
}, |
|
|
|
importTypeClick(data){ |
|
|
|
importTypeClick(data){ |
|
|
|
|
|
|
|
// 如果点击的是表,则加载这个表下面的字段,分类则不用 |
|
|
|
if(data.name){ |
|
|
|
if(data.name){ |
|
|
|
this.tableName = data.name |
|
|
|
this.tableName = data.name |
|
|
|
this.curId = data.id |
|
|
|
this.curId = data.id |
|
|
|
this.getFields() |
|
|
|
this.getFields() |
|
|
|
} |
|
|
|
} |
|
|
|
}, |
|
|
|
}, |
|
|
|
|
|
|
|
// 分类展开的回调 |
|
|
|
importTypeExpand(obj,node,com){ |
|
|
|
importTypeExpand(obj,node,com){ |
|
|
|
this.curExpand = obj.id |
|
|
|
this.curExpand = obj.id |
|
|
|
this.$refs.typeTree.setCheckedKeys(this.defaultTypeChecked) |
|
|
|
this.renderChecked() |
|
|
|
}, |
|
|
|
}, |
|
|
|
closeImport(){ |
|
|
|
closeImport(){ |
|
|
|
this.$refs.typeTree.setCheckedKeys([]) |
|
|
|
this.$refs.typeTree.setCheckedKeys([]) |
|
|
|
this.names = [] |
|
|
|
this.names = [] |
|
|
|
this.showNames = [] |
|
|
|
this.showNames = [] |
|
|
|
}, |
|
|
|
}, |
|
|
|
|
|
|
|
// 获取names和showNames,提交的时候需要 |
|
|
|
getNames(){ |
|
|
|
getNames(){ |
|
|
|
|
|
|
|
// 获取已经勾选的分类 |
|
|
|
let list = this.$refs.typeTree.getCheckedNodes() |
|
|
|
let list = this.$refs.typeTree.getCheckedNodes() |
|
|
|
return new Promise((resolve,reject) => { |
|
|
|
return new Promise((resolve,reject) => { |
|
|
|
let getLen = 0 |
|
|
|
let getLen = 0 |
|
|
|
list.map(n => { |
|
|
|
list.map(n => { |
|
|
|
|
|
|
|
// 如果tableLen大于子级的数量,则表示这个分类下的子级是没有全部加载出来的,要在下面去查询出来,这里先记载要查询的分类数量 |
|
|
|
if(n.tableLen && n.tableLen > n.children.length) getLen++ |
|
|
|
if(n.tableLen && n.tableLen > n.children.length) getLen++ |
|
|
|
}) |
|
|
|
}) |
|
|
|
list.map((n,i) => { |
|
|
|
list.map((n,i) => { |
|
|
|
if(n.tableLen && n.tableLen > n.children.length){ |
|
|
|
if(n.tableLen && n.tableLen > n.children.length){ |
|
|
|
|
|
|
|
// pageSize传10000是要查询全部表,后续如果数据多了,则按需调整 |
|
|
|
this.$post(`${this.api.originalListById}?categoryId=${n.realId}&pageNum=1&pageSize=10000`).then(res => { |
|
|
|
this.$post(`${this.api.originalListById}?categoryId=${n.realId}&pageNum=1&pageSize=10000`).then(res => { |
|
|
|
let tableList = res.list.records |
|
|
|
let tableList = res.list.records |
|
|
|
|
|
|
|
// 查询完1个,则数量-1 |
|
|
|
getLen-- |
|
|
|
getLen-- |
|
|
|
tableList.map(n => { |
|
|
|
tableList.map(n => { |
|
|
|
|
|
|
|
// 如果是默认没有的表,则添加进去 |
|
|
|
if(!this.defaultTypeChecked.includes(String(n.id))){ |
|
|
|
if(!this.defaultTypeChecked.includes(String(n.id))){ |
|
|
|
this.names.push(n.name) |
|
|
|
this.names.push(n.name) |
|
|
|
this.showNames.push(n.showName) |
|
|
|
this.showNames.push(n.showName) |
|
|
|
} |
|
|
|
} |
|
|
|
}) |
|
|
|
}) |
|
|
|
|
|
|
|
// 清0后,才执行resolve |
|
|
|
if(!getLen) resolve() |
|
|
|
if(!getLen) resolve() |
|
|
|
}).catch(res => {}) |
|
|
|
}).catch(res => {}) |
|
|
|
}else if(n.name && !n.disabled && !this.names.includes(n.name)){ |
|
|
|
}else if(n.name && !n.disabled && !this.names.includes(n.name)){ // 如果是表,并且不是存在于分类下了的表,并且没重复,则添加进去 |
|
|
|
this.names.push(n.name) |
|
|
|
this.names.push(n.name) |
|
|
|
this.showNames.push(n.showName) |
|
|
|
this.showNames.push(n.showName) |
|
|
|
if(!getLen) resolve() |
|
|
|
if(!getLen) resolve() |
|
|
@ -468,6 +491,7 @@ export default { |
|
|
|
}, |
|
|
|
}, |
|
|
|
confirmImport(){ |
|
|
|
confirmImport(){ |
|
|
|
if(this.submited) return false |
|
|
|
if(this.submited) return false |
|
|
|
|
|
|
|
// 如果没有选择任何数据 |
|
|
|
if(!this.$refs.typeTree.getCheckedNodes().length) return this.$message.warning('请选择数据') |
|
|
|
if(!this.$refs.typeTree.getCheckedNodes().length) return this.$message.warning('请选择数据') |
|
|
|
this.getNames().then(() => { |
|
|
|
this.getNames().then(() => { |
|
|
|
let names = Array.from(new Set(this.names)) |
|
|
|
let names = Array.from(new Set(this.names)) |
|
|
|