|
|
@ -5,7 +5,7 @@ |
|
|
|
<div class="plus"> |
|
|
|
<div class="plus"> |
|
|
|
<i class="el-icon-circle-plus-outline" @click.stop="addType(0)"></i> |
|
|
|
<i class="el-icon-circle-plus-outline" @click.stop="addType(0)"></i> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
<el-tree ref="type" :data="typeList" node-key="id" accordion :default-expanded-keys="defaultActive" :current-node-key="categoryId" :props="defaultProps" :highlight-current="true" @current-change="typeClick"> |
|
|
|
<el-tree ref="type" :load="getType" lazy node-key="id" accordion :default-expanded-keys="defaultActive" :current-node-key="categoryId" :props="defaultProps" :highlight-current="true" @current-change="typeClick"> |
|
|
|
<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"> |
|
|
@ -156,10 +156,9 @@ |
|
|
|
export default { |
|
|
|
export default { |
|
|
|
data() { |
|
|
|
data() { |
|
|
|
return { |
|
|
|
return { |
|
|
|
typeList: [], |
|
|
|
|
|
|
|
defaultProps: { |
|
|
|
defaultProps: { |
|
|
|
children: 'children', |
|
|
|
children: 'children', |
|
|
|
label: 'label' |
|
|
|
label: 'categoryName' |
|
|
|
}, |
|
|
|
}, |
|
|
|
defaultActive: [], |
|
|
|
defaultActive: [], |
|
|
|
added: false, |
|
|
|
added: false, |
|
|
@ -195,11 +194,13 @@ export default { |
|
|
|
curComment: [], |
|
|
|
curComment: [], |
|
|
|
submited: false, |
|
|
|
submited: false, |
|
|
|
names: [], |
|
|
|
names: [], |
|
|
|
showNames: [], |
|
|
|
|
|
|
|
nameVisible: false, |
|
|
|
nameVisible: false, |
|
|
|
curRow: {}, |
|
|
|
curRow: {}, |
|
|
|
headVisible: false, |
|
|
|
headVisible: false, |
|
|
|
editIndex: 0 |
|
|
|
editIndex: 0, |
|
|
|
|
|
|
|
node: [], |
|
|
|
|
|
|
|
resolve: null, |
|
|
|
|
|
|
|
curNode: {} |
|
|
|
}; |
|
|
|
}; |
|
|
|
}, |
|
|
|
}, |
|
|
|
watch: { |
|
|
|
watch: { |
|
|
@ -210,37 +211,20 @@ export default { |
|
|
|
},500) |
|
|
|
},500) |
|
|
|
} |
|
|
|
} |
|
|
|
}, |
|
|
|
}, |
|
|
|
mounted(){ |
|
|
|
mounted(){}, |
|
|
|
this.getType() |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
methods: { |
|
|
|
methods: { |
|
|
|
getType(){ |
|
|
|
getType(node, resolve){ |
|
|
|
this.$post(this.api.getTableByClassification).then(res => { |
|
|
|
this.$post(`${this.api.getLevel}?parentId=${node.level ? node.data.id : 0}`).then(res => { |
|
|
|
// 递归赋值,同时添加层级标识 |
|
|
|
const list = res.list |
|
|
|
function handleId(data,level = 0){ |
|
|
|
this.node = node |
|
|
|
data.map(n => { |
|
|
|
this.resolve = resolve |
|
|
|
n.id = String(n.id) |
|
|
|
resolve(list) |
|
|
|
n.label = n.categoryName |
|
|
|
|
|
|
|
n.level = level + 1 |
|
|
|
|
|
|
|
if(n.children.length){ |
|
|
|
|
|
|
|
handleId(n.children,n.level) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
handleId(res) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this.typeList = res |
|
|
|
|
|
|
|
if (!this.added) { |
|
|
|
|
|
|
|
if(res[0].children.length){ |
|
|
|
|
|
|
|
this.categoryId = res[0].children[0].id |
|
|
|
|
|
|
|
this.defaultActive = [res[0].children[0].id] |
|
|
|
|
|
|
|
}else{ |
|
|
|
|
|
|
|
this.categoryId = res[0].id |
|
|
|
|
|
|
|
this.defaultActive = [res[0].id] |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
// 取第一个分类的id |
|
|
|
// 取第一个分类的id |
|
|
|
|
|
|
|
if (!this.added && list.length) { |
|
|
|
|
|
|
|
this.categoryId = list[0].id |
|
|
|
|
|
|
|
this.defaultActive = [list[0].id] |
|
|
|
this.$nextTick(() => { |
|
|
|
this.$nextTick(() => { |
|
|
|
this.$refs.type.setCurrentKey(res[0].children[0].id) |
|
|
|
this.$refs.type.setCurrentKey(list[0].id) |
|
|
|
}) |
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
|
this.added = false |
|
|
|
this.added = false |
|
|
@ -274,6 +258,7 @@ export default { |
|
|
|
this.getData() |
|
|
|
this.getData() |
|
|
|
}, |
|
|
|
}, |
|
|
|
addType(row){ |
|
|
|
addType(row){ |
|
|
|
|
|
|
|
this.categoryId = row.data.id |
|
|
|
if (row) this.defaultActive = [row.data.id] |
|
|
|
if (row) this.defaultActive = [row.data.id] |
|
|
|
this.typeVisible = true |
|
|
|
this.typeVisible = true |
|
|
|
this.levelId = row ? row.data.id : 0 |
|
|
|
this.levelId = row ? row.data.id : 0 |
|
|
@ -282,6 +267,8 @@ export default { |
|
|
|
this.typeVisible = true |
|
|
|
this.typeVisible = true |
|
|
|
this.id = row.data.id |
|
|
|
this.id = row.data.id |
|
|
|
this.categoryName = row.data.categoryName |
|
|
|
this.categoryName = row.data.categoryName |
|
|
|
|
|
|
|
this.curNode = row |
|
|
|
|
|
|
|
this.categoryId = row.data.id |
|
|
|
}, |
|
|
|
}, |
|
|
|
delType(row){ |
|
|
|
delType(row){ |
|
|
|
// 该分类下的数据表已存在于产品管理中,是否确认删除? |
|
|
|
// 该分类下的数据表已存在于产品管理中,是否确认删除? |
|
|
@ -291,7 +278,7 @@ export default { |
|
|
|
this.added = true |
|
|
|
this.added = true |
|
|
|
this.$post(`${this.api.deleteCategory}?categoryId=${row.data.id}`).then(res => { |
|
|
|
this.$post(`${this.api.deleteCategory}?categoryId=${row.data.id}`).then(res => { |
|
|
|
this.$message.success('删除成功') |
|
|
|
this.$message.success('删除成功') |
|
|
|
this.getType() |
|
|
|
this.$refs.type.remove(row) |
|
|
|
}).catch(res => {}) |
|
|
|
}).catch(res => {}) |
|
|
|
}).catch(() => {}) |
|
|
|
}).catch(() => {}) |
|
|
|
}, |
|
|
|
}, |
|
|
@ -305,7 +292,9 @@ export default { |
|
|
|
categoryName: this.categoryName |
|
|
|
categoryName: this.categoryName |
|
|
|
}).then(res => { |
|
|
|
}).then(res => { |
|
|
|
this.$message.success('编辑成功') |
|
|
|
this.$message.success('编辑成功') |
|
|
|
this.getType() |
|
|
|
this.curNode.data.categoryName = this.categoryName |
|
|
|
|
|
|
|
this.$refs.type.updateKeyChildren(this.id, this.curNode) |
|
|
|
|
|
|
|
this.getType(this.node, this.resolve) |
|
|
|
this.typeVisible = false |
|
|
|
this.typeVisible = false |
|
|
|
setTimeout(() => { |
|
|
|
setTimeout(() => { |
|
|
|
this.submited = false |
|
|
|
this.submited = false |
|
|
@ -319,7 +308,10 @@ export default { |
|
|
|
categoryName: this.categoryName |
|
|
|
categoryName: this.categoryName |
|
|
|
}).then(res => { |
|
|
|
}).then(res => { |
|
|
|
this.$message.success('添加成功') |
|
|
|
this.$message.success('添加成功') |
|
|
|
this.getType() |
|
|
|
this.getType(this.node, this.resolve) |
|
|
|
|
|
|
|
let node = this.$refs.type.getNode(this.categoryId) |
|
|
|
|
|
|
|
node.loaded = false |
|
|
|
|
|
|
|
node.expand() |
|
|
|
this.typeVisible = false |
|
|
|
this.typeVisible = false |
|
|
|
setTimeout(() => { |
|
|
|
setTimeout(() => { |
|
|
|
this.submited = false |
|
|
|
this.submited = false |
|
|
@ -492,7 +484,7 @@ export default { |
|
|
|
data.map(n => { |
|
|
|
data.map(n => { |
|
|
|
that.importTypeIndex++ |
|
|
|
that.importTypeIndex++ |
|
|
|
n.realId = n.id |
|
|
|
n.realId = n.id |
|
|
|
// 分类id跟表id可能是冲突,所以就加了个基数,后续再优化 |
|
|
|
// 分类id跟表id可能会冲突,所以就加了个基数 |
|
|
|
n.id = String(that.importTypeIndex + n.id) |
|
|
|
n.id = String(that.importTypeIndex + n.id) |
|
|
|
n.label = n.categoryName |
|
|
|
n.label = n.categoryName |
|
|
|
if(n.children.length){ |
|
|
|
if(n.children.length){ |
|
|
@ -501,7 +493,7 @@ export default { |
|
|
|
}) |
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
|
handleId(res) |
|
|
|
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 |
|
|
|
let list = res1.pageList.records |
|
|
|
this.defaultTypeChecked = list.map(n => n.copyId) |
|
|
|
this.defaultTypeChecked = list.map(n => n.copyId) |
|
|
|
const that = this |
|
|
|
const that = this |
|
|
@ -562,74 +554,58 @@ export default { |
|
|
|
closeImport(){ |
|
|
|
closeImport(){ |
|
|
|
this.$refs.typeTree.setCheckedKeys([]) |
|
|
|
this.$refs.typeTree.setCheckedKeys([]) |
|
|
|
this.names = [] |
|
|
|
this.names = [] |
|
|
|
this.showNames = [] |
|
|
|
|
|
|
|
}, |
|
|
|
}, |
|
|
|
// 获取names和showNames,提交的时候需要 |
|
|
|
// 获取names和showNames,提交的时候需要 |
|
|
|
getNames(){ |
|
|
|
getNames(list){ |
|
|
|
// 获取已经勾选的分类 |
|
|
|
const categoryId = Number(this.categoryId) |
|
|
|
let list = this.$refs.typeTree.getCheckedNodes() |
|
|
|
|
|
|
|
return new Promise((resolve,reject) => { |
|
|
|
return new Promise((resolve,reject) => { |
|
|
|
let getLen = 0 |
|
|
|
// 根据选择的分类id查询下面的表id |
|
|
|
list.map(n => { |
|
|
|
this.$get(`${this.api.getAllTableInfoByCategoryId}?categoryId=${list.join()}`).then(res => { |
|
|
|
// 如果tableLen大于子级的数量,则表示这个分类下的子级是没有全部加载出来的,要在下面去查询出来,这里先记载要查询的分类数量 |
|
|
|
const list = res.tableInfo |
|
|
|
if(n.tableLen && n.tableLen > n.children.length) getLen++ |
|
|
|
list.map(e => { |
|
|
|
}) |
|
|
|
delete e.id |
|
|
|
list.map((n,i) => { |
|
|
|
e.categoryId = categoryId |
|
|
|
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 |
|
|
|
this.names = list |
|
|
|
if(!getLen) resolve() |
|
|
|
resolve() |
|
|
|
}).catch(res => {}) |
|
|
|
}).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() |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
}) |
|
|
|
}) |
|
|
|
}, |
|
|
|
}, |
|
|
|
confirmImport(){ |
|
|
|
confirmImport(){ |
|
|
|
if(this.submited) return false |
|
|
|
if(this.submited) return false |
|
|
|
|
|
|
|
const checked = this.$refs.typeTree.getCheckedNodes() // 勾选的数据 |
|
|
|
// 如果没有选择任何数据 |
|
|
|
// 如果没有选择任何数据 |
|
|
|
if(!this.$refs.typeTree.getCheckedNodes().length) return this.$message.warning('请选择数据') |
|
|
|
if(!checked.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 |
|
|
|
this.submited = true |
|
|
|
let data = [] |
|
|
|
const typeIds = checked.filter(e => !e.name).map(e => e.realId) // 先筛选出分类id,再获取分类真正的id |
|
|
|
let categoryId = Number(this.categoryId) |
|
|
|
this.getNames(typeIds).then(() => { |
|
|
|
names.map((n,i) => { |
|
|
|
const data = this.names |
|
|
|
data.push({ |
|
|
|
const dataList = [] |
|
|
|
categoryId, |
|
|
|
for (let i = 0, len = data.length; i < len; i += 2000) { |
|
|
|
name: n, |
|
|
|
dataList.push(data.slice(i, i + 2000)) |
|
|
|
showName: showNames[i], |
|
|
|
} |
|
|
|
|
|
|
|
const promiseList = [] |
|
|
|
|
|
|
|
dataList.map(e => { |
|
|
|
|
|
|
|
promiseList.push(new Promise((resolve,reject) => { |
|
|
|
|
|
|
|
this.$post(this.api.saveTable, e).then(res => { |
|
|
|
|
|
|
|
resolve() |
|
|
|
|
|
|
|
}).catch(res => { |
|
|
|
|
|
|
|
reject() |
|
|
|
}) |
|
|
|
}) |
|
|
|
|
|
|
|
})) |
|
|
|
}) |
|
|
|
}) |
|
|
|
this.$post(this.api.saveTable,data).then(res => { |
|
|
|
Promise.all(promiseList).then(res => { |
|
|
|
this.$message.success('导入成功') |
|
|
|
this.$message.success('导入成功') |
|
|
|
this.getData() |
|
|
|
this.getData() |
|
|
|
this.importVisible = false |
|
|
|
this.importVisible = false |
|
|
|
setTimeout(() => { |
|
|
|
setTimeout(() => { |
|
|
|
this.submited = false |
|
|
|
this.submited = false |
|
|
|
},1000) |
|
|
|
},1000) |
|
|
|
}).catch(res => { |
|
|
|
}).catch(err => { |
|
|
|
this.submited = false |
|
|
|
this.submited = false |
|
|
|
}) |
|
|
|
}) |
|
|
|
}) |
|
|
|
}) |
|
|
|
}, |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
}; |
|
|
|
}; |
|
|
|
</script> |
|
|
|
</script> |
|
|
|