Compare commits

..

No commits in common. "e8511f865a7dfedc4cf579cb70fd0ee6388ed680" and "4583ef457409cc3d0ebab3f6b0ee9fbf88901c64" have entirely different histories.

3 changed files with 7 additions and 167 deletions

View File

@ -37,7 +37,6 @@ import TreeStore from "./model/tree-store.js";
import { getNodeKey } from "./model/util";
export default {
name: "OkrTree",
inject: ["eventBus"],
components: {
OkrTreeNode,
},
@ -161,7 +160,6 @@ export default {
animateName: this.animateName,
});
this.root = this.store.root;
this.okrEventBus.$on("inputCompleted", this.handleInputCompleted);
},
watch: {
data(newVal) {

View File

@ -145,42 +145,14 @@
></OkrTreeNode>
</div>
</transition>
<!-- 新增的输入框和显示区域 -->
<div
v-if="isInputVisible"
class="input-container"
>
<el-input
type="text"
v-model="inputValue"
@keyup.native.enter="handleInputEnter"
@blur="handleBlur"
maxlength="30"
show-word-limit
placeholder="输入点检结果..."
/>
</div>
<div
v-if="inputDisplayText"
class="input-display"
>
{{ inputDisplayText }}
</div>
<el-button
v-if="inputDisplayText"
class="input-button"
type="text"
@click="editInput()"
>编辑</el-button>
</div>
</template>
<script>
import { getNodeKey } from "./model/util";
import _ from "lodash";
export default {
name: "OkrTreeNode",
inject: ["okrEventBus", "eventBus"],
inject: ["okrEventBus"],
props: {
props: {},
node: {
@ -432,11 +404,6 @@ export default {
// node
expanded: false,
tree: null,
//
isInputVisible: false,
inputValue: "",
inputDisplayText: "",
isEnter: false,
};
},
created() {
@ -453,64 +420,13 @@ export default {
}
},
methods: {
editInput() {
this.inputValue = this.inputDisplayText;
this.inputDisplayText = false;
this.isInputVisible = true;
},
//
showInput() {
this.isInputVisible = true;
this.$nextTick(() => {
this.$el.querySelector("input").focus();
});
},
handleBlur() {
if (!this.isEnter) {
this.inputDisplayText = this.inputValue;
this.eventBus.$emit("inputCompleted", {
node: this.node,
inputValue: this.inputValue,
});
this.inputValue = "";
this.isInputVisible = false;
}
this.isEnter = false;
},
handleInputEnter() {
this.isEnter = true;
this.inputDisplayText = this.inputValue;
this.eventBus.$emit("inputCompleted", {
node: this.node,
inputValue: this.inputValue,
});
this.inputValue = "";
this.isInputVisible = false;
//
},
handleInputBlur() {
if (!this.inputValue) {
this.isInputVisible = false;
}
},
// handleNodeClick
toggleInput() {
if (this.isInputVisible) {
this.handleInputBlur();
} else {
this.showInput();
}
},
getNodeKey(node) {
return getNodeKey(this.nodeKey, node.data);
},
handleNodeClick(node) {
handleNodeClick() {
const store = this.tree.store;
store.setCurrentNode(this.node);
this.tree.$emit("node-click", this.node.data, this.node, this);
if (this.node.isLeaf && this.node.childNodes) {
this.toggleInput();
} //
},
handleBtnClick(isLeft) {
isLeft = isLeft === "left";
@ -555,32 +471,3 @@ export default {
},
};
</script>
<style scoped>
/* 新增的样式 */
.input-container {
/* margin-top: 10px; */
margin-left: 10px;
}
.input-container input {
padding: 5px;
border: 1px solid #ccc;
border-radius: 4px;
width: 100%; /* 或者你需要的宽度 */
box-sizing: border-box;
}
.input-display {
margin-left: 10px;
color: #666;
font-size: 16px;
width: 150px; /* 设置div的宽度 */
white-space: nowrap; /* 确保文本在一行内显示 */
overflow: hidden; /* 隐藏超出div宽度的文本 */
text-overflow: ellipsis; /* 使用省略号表示被截断的文本 */
}
.input-button {
text-align: center;
align-items: center;
}
</style>

View File

@ -24,38 +24,14 @@
default-expand-all
:current-lable-class-name="renderCurrentClass"
@node-click="nodeClick"
></vue-okr-tree>
</div>
</el-checkbox>
</el-checkbox-group>
<div
v-for="(tree,index) in treeData"
:key="tree.inspectionPlanId"
:label="tree.inspectionPlanId"
>
<div
class="component-wrapper"
style="margin:0 3%;"
>
<vue-okr-tree
class="custom-tree"
:data="objToList(tree)"
node-key="nodeId"
direction="horizontal"
:props="props"
show-collapsable
default-expand-all
:current-lable-class-name="renderCurrentClass"
@node-click="nodeClick"
@comment-submitted="handleCommentSubmitted"
>
</vue-okr-tree>
</div>
</div>
</el-checkbox>
</el-checkbox-group>
</div>
</template>
<script>
import Vue from "vue";
import { VueOkrTree } from "@/components/VueOkrTree/index.js";
import * as InspectionPlanApi from "@/api/system/inspection/plan";
import alipayChannelFormVue from "../../pay/app/components/alipayChannelForm.vue";
@ -66,7 +42,6 @@ export default {
},
data() {
return {
eventBus: new Vue(),
treeData: [
{
id: 0,
@ -130,36 +105,16 @@ export default {
label: "inspectionName",
},
selectedTreeList: [],
textarea: "",
};
},
provide() {
return {
eventBus: this.eventBus,
};
},
mounted() {
// this.toggleExpand(this.data, true);
this.getList();
},
created() {
this.eventBus.$on("inputCompleted", this.handleGlobalInputCompleted);
},
beforeDestroy() {
this.eventBus.$off("inputCompleted");
},
methods: {
handleGlobalInputCompleted({ node, inputValue }) {
//
console.log("全局节点信息:", node);
console.log("全局输入值:", inputValue);
//
},
nodeClick(node) {
// console.log("Node clicked:", node);
},
handleCommentSubmitted(node, content) {
console.log("Comment submitted for node:", node, "Content:", content);
nodeClick(obj, node) {
console.log("点击obj:", obj);
console.log("点击node:", node);
},
renderCurrentClass(node) {
return "label-bg-blue";