Merge remote-tracking branch 'origin/test'

This commit is contained in:
fan 2024-03-05 13:53:17 +08:00
commit 2ae715a936

View File

@ -21,11 +21,14 @@
:data="taskDta" :data="taskDta"
node-key="id" node-key="id"
default-expand-all default-expand-all
:props="defaultProps"
:expand-on-click-node="false" :expand-on-click-node="false"
> >
<span slot-scope="{ node, data }" class="custom-tree-node"> <div slot-scope="{ node, data }" class="custom-tree-node">
<span>{{ node.label }}</span> <div class="left-label" :title="node.label">
<span> {{ node.label }}
</div>
<div class="right-button">
<el-button <el-button
type="text" type="text"
size="mini" size="mini"
@ -55,8 +58,8 @@
> >
任务绑定 任务绑定
</el-button> </el-button>
</span> </div>
</span> </div>
</el-tree> </el-tree>
</el-card> </el-card>
<add-edit-task ref="addEditTask" @reloadTaskTree="getTreeData" /> <add-edit-task ref="addEditTask" @reloadTaskTree="getTreeData" />
@ -76,7 +79,13 @@ export default {
}, },
data() { data() {
return { return {
taskDta:[] taskDta:[],
defaultProps: {
children: 'children',
label: 'name',
id: 'id',
parentId:'parentId'
}
}; };
}, },
created() { created() {
@ -86,7 +95,7 @@ export default {
methods: { methods: {
getTreeData() { getTreeData() {
getTaskTreeDatas().then((res) => { getTaskTreeDatas().then((res) => {
this.taskDta = this.transformTree(res.data); this.taskDta = res.data;
}).catch(error => { }).catch(error => {
this.$message.error(error.message); this.$message.error(error.message);
}); });
@ -126,22 +135,6 @@ export default {
this.$message({ type: 'error', message: res.message }); this.$message({ type: 'error', message: res.message });
} }
}); });
},
transformTree(data) {
const result = [];
for (let i = 0; i < data.length; i++) {
const node = data[i];
const item = {
id: node.id,
label: node.name,
parentId:node.parentId
};
if (node.children) {
item.children = this.transformTree(node.children);
}
result.push(item);
}
return result;
} }
} }
}; };
@ -149,8 +142,9 @@ export default {
<style lang="scss" scoped> <style lang="scss" scoped>
.taskContainer{ .taskContainer{
width: 50%; width: 70%;
margin: 0 auto; margin: 0 auto;
overflow: hidden;
.taskTitle { .taskTitle {
display: flex; display: flex;
align-items: center; align-items: center;
@ -158,12 +152,22 @@ export default {
padding: 10px; padding: 10px;
} }
.custom-tree-node { .custom-tree-node {
flex: 1;
display: flex; display: flex;
align-items: center; align-items: center;
justify-content: space-between; justify-content: space-between;
width: 100%;
font-size: 16px; font-size: 16px;
padding-right: 20px; padding-right: 20px;
.left-label{
flex: 1;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
cursor: pointer;
}
.right-button{
width:255px;
}
} }
} }