fix table重新渲染会修改props
This commit is contained in:
parent
71a3b6f1c4
commit
9c7280105d
@ -1058,7 +1058,7 @@ const _sfc_main = defineComponent({
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
findFinalNode(0, tableColumns.value);
|
findFinalNode(0, tableColumns.value);
|
||||||
const tableSelectedKeys = ref([...props.selectedKeys]);
|
const tableSelectedKeys = ref(props.selectedKeys);
|
||||||
const tableExpandKeys = ref([...props.expandKeys]);
|
const tableExpandKeys = ref([...props.expandKeys]);
|
||||||
watch(() => props.selectedKeys, () => {
|
watch(() => props.selectedKeys, () => {
|
||||||
tableSelectedKeys.value = props.selectedKeys;
|
tableSelectedKeys.value = props.selectedKeys;
|
||||||
@ -1102,7 +1102,10 @@ const _sfc_main = defineComponent({
|
|||||||
} else {
|
} else {
|
||||||
hasChecked.value = false;
|
hasChecked.value = false;
|
||||||
}
|
}
|
||||||
emit("update:selectedKeys", tableSelectedKeys.value);
|
if (tableSelectedKeys.value != props.selectedKeys) {
|
||||||
|
console.log("\u521D\u59CB\u5316\u8D4B\u503C\u89E6\u53D1\u4FEE\u6539", tableSelectedKeys.value, props.selectedKeys);
|
||||||
|
emit("update:selectedKeys", tableSelectedKeys.value);
|
||||||
|
}
|
||||||
}, { deep: true, immediate: true });
|
}, { deep: true, immediate: true });
|
||||||
watch(tableExpandKeys, () => {
|
watch(tableExpandKeys, () => {
|
||||||
emit("update:expandKeys", tableExpandKeys.value);
|
emit("update:expandKeys", tableExpandKeys.value);
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import { w as withInstall } from "../badge/index2.js";
|
import { w as withInstall } from "../badge/index2.js";
|
||||||
import { defineComponent, useSlots, computed, resolveComponent, openBlock, createElementBlock, Fragment, renderList, normalizeClass, createElementVNode, createVNode, unref, withModifiers, createBlock, createCommentVNode, renderSlot, createTextVNode, toDisplayString, withCtx, createSlots, ref, watch, onMounted, nextTick } from "vue";
|
import { defineComponent, useSlots, computed, resolveComponent, openBlock, createElementBlock, Fragment, renderList, normalizeClass, createElementVNode, createVNode, unref, withModifiers, createBlock, createCommentVNode, renderSlot, createTextVNode, toDisplayString, withCtx, createSlots, ref, watch, nextTick, onMounted } from "vue";
|
||||||
import { _ as _sfc_main$2E, a as _sfc_main$2 } from "../checkbox/index2.js";
|
import { _ as _sfc_main$2E, a as _sfc_main$2 } from "../checkbox/index2.js";
|
||||||
import { _ as _sfc_main$3 } from "../transition/index2.js";
|
import { _ as _sfc_main$3 } from "../transition/index2.js";
|
||||||
const _hoisted_1 = ["onClick"];
|
const _hoisted_1 = ["onClick"];
|
||||||
@ -65,6 +65,9 @@ const _sfc_main$1 = defineComponent({
|
|||||||
if (!node.isDisabled) {
|
if (!node.isDisabled) {
|
||||||
emit("node-click", node);
|
emit("node-click", node);
|
||||||
}
|
}
|
||||||
|
if (props.showCheckbox) {
|
||||||
|
node.isChecked = !node.isChecked;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
function handleRowClick(node) {
|
function handleRowClick(node) {
|
||||||
if (!props.showLine) {
|
if (!props.showLine) {
|
||||||
@ -146,7 +149,7 @@ const _sfc_main$1 = defineComponent({
|
|||||||
class: normalizeClass({
|
class: normalizeClass({
|
||||||
"layui-tree-txt": true,
|
"layui-tree-txt": true,
|
||||||
"layui-disabled": node.isDisabled,
|
"layui-disabled": node.isDisabled,
|
||||||
"layui-this": __props.selectedKey === node.id
|
"layui-this": __props.selectedKey === node.id || node.isChecked
|
||||||
}),
|
}),
|
||||||
onClick: withModifiers(($event) => handleTitleClick(node), ["stop"])
|
onClick: withModifiers(($event) => handleTitleClick(node), ["stop"])
|
||||||
}, [
|
}, [
|
||||||
@ -418,18 +421,21 @@ const _sfc_main = defineComponent({
|
|||||||
loadNodeList();
|
loadNodeList();
|
||||||
}, { deep: true, immediate: true });
|
}, { deep: true, immediate: true });
|
||||||
watch(() => props.checkedKeys, () => {
|
watch(() => props.checkedKeys, () => {
|
||||||
|
console.log(tree.value);
|
||||||
if (!unWatch.value) {
|
if (!unWatch.value) {
|
||||||
loadNodeList();
|
loadNodeList();
|
||||||
}
|
}
|
||||||
|
}, {
|
||||||
|
deep: true
|
||||||
});
|
});
|
||||||
watch(tree, () => {
|
watch(tree, () => {
|
||||||
if (initStatus.value) {
|
if (initStatus.value) {
|
||||||
const { checkedKeys } = tree.value.getKeys();
|
const { checkedKeys } = tree.value.getKeys();
|
||||||
unWatch.value = true;
|
unWatch.value = true;
|
||||||
emit("update:checkedKeys", checkedKeys);
|
emit("update:checkedKeys", checkedKeys);
|
||||||
setTimeout(() => {
|
nextTick(() => {
|
||||||
unWatch.value = false;
|
unWatch.value = false;
|
||||||
}, 0);
|
});
|
||||||
}
|
}
|
||||||
}, { deep: true });
|
}, { deep: true });
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
|
@ -17662,6 +17662,9 @@ const _sfc_main$K = defineComponent({
|
|||||||
if (!node.isDisabled) {
|
if (!node.isDisabled) {
|
||||||
emit("node-click", node);
|
emit("node-click", node);
|
||||||
}
|
}
|
||||||
|
if (props.showCheckbox) {
|
||||||
|
node.isChecked = !node.isChecked;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
function handleRowClick(node) {
|
function handleRowClick(node) {
|
||||||
if (!props.showLine) {
|
if (!props.showLine) {
|
||||||
@ -17743,7 +17746,7 @@ const _sfc_main$K = defineComponent({
|
|||||||
class: normalizeClass({
|
class: normalizeClass({
|
||||||
"layui-tree-txt": true,
|
"layui-tree-txt": true,
|
||||||
"layui-disabled": node.isDisabled,
|
"layui-disabled": node.isDisabled,
|
||||||
"layui-this": __props.selectedKey === node.id
|
"layui-this": __props.selectedKey === node.id || node.isChecked
|
||||||
}),
|
}),
|
||||||
onClick: withModifiers(($event) => handleTitleClick(node), ["stop"])
|
onClick: withModifiers(($event) => handleTitleClick(node), ["stop"])
|
||||||
}, [
|
}, [
|
||||||
@ -18015,18 +18018,21 @@ const _sfc_main$J = defineComponent({
|
|||||||
loadNodeList();
|
loadNodeList();
|
||||||
}, { deep: true, immediate: true });
|
}, { deep: true, immediate: true });
|
||||||
watch(() => props.checkedKeys, () => {
|
watch(() => props.checkedKeys, () => {
|
||||||
|
console.log(tree.value);
|
||||||
if (!unWatch.value) {
|
if (!unWatch.value) {
|
||||||
loadNodeList();
|
loadNodeList();
|
||||||
}
|
}
|
||||||
|
}, {
|
||||||
|
deep: true
|
||||||
});
|
});
|
||||||
watch(tree, () => {
|
watch(tree, () => {
|
||||||
if (initStatus.value) {
|
if (initStatus.value) {
|
||||||
const { checkedKeys } = tree.value.getKeys();
|
const { checkedKeys } = tree.value.getKeys();
|
||||||
unWatch.value = true;
|
unWatch.value = true;
|
||||||
emit("update:checkedKeys", checkedKeys);
|
emit("update:checkedKeys", checkedKeys);
|
||||||
setTimeout(() => {
|
nextTick(() => {
|
||||||
unWatch.value = false;
|
unWatch.value = false;
|
||||||
}, 0);
|
});
|
||||||
}
|
}
|
||||||
}, { deep: true });
|
}, { deep: true });
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
@ -19492,7 +19498,7 @@ const _sfc_main$D = defineComponent({
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
findFinalNode(0, tableColumns.value);
|
findFinalNode(0, tableColumns.value);
|
||||||
const tableSelectedKeys = ref([...props.selectedKeys]);
|
const tableSelectedKeys = ref(props.selectedKeys);
|
||||||
const tableExpandKeys = ref([...props.expandKeys]);
|
const tableExpandKeys = ref([...props.expandKeys]);
|
||||||
watch(() => props.selectedKeys, () => {
|
watch(() => props.selectedKeys, () => {
|
||||||
tableSelectedKeys.value = props.selectedKeys;
|
tableSelectedKeys.value = props.selectedKeys;
|
||||||
@ -19536,7 +19542,10 @@ const _sfc_main$D = defineComponent({
|
|||||||
} else {
|
} else {
|
||||||
hasChecked.value = false;
|
hasChecked.value = false;
|
||||||
}
|
}
|
||||||
emit("update:selectedKeys", tableSelectedKeys.value);
|
if (tableSelectedKeys.value != props.selectedKeys) {
|
||||||
|
console.log("\u521D\u59CB\u5316\u8D4B\u503C\u89E6\u53D1\u4FEE\u6539", tableSelectedKeys.value, props.selectedKeys);
|
||||||
|
emit("update:selectedKeys", tableSelectedKeys.value);
|
||||||
|
}
|
||||||
}, { deep: true, immediate: true });
|
}, { deep: true, immediate: true });
|
||||||
watch(tableExpandKeys, () => {
|
watch(tableExpandKeys, () => {
|
||||||
emit("update:expandKeys", tableExpandKeys.value);
|
emit("update:expandKeys", tableExpandKeys.value);
|
||||||
|
@ -238,7 +238,8 @@ const findFinalNode = (level: number, columns: any[]) => {
|
|||||||
|
|
||||||
findFinalNode(0, tableColumns.value);
|
findFinalNode(0, tableColumns.value);
|
||||||
|
|
||||||
const tableSelectedKeys = ref<Recordable[]>([...props.selectedKeys]);
|
// 你浅拷贝他干什么呀
|
||||||
|
const tableSelectedKeys = ref<Recordable[]>(props.selectedKeys);
|
||||||
const tableExpandKeys = ref<Recordable[]>([...props.expandKeys]);
|
const tableExpandKeys = ref<Recordable[]>([...props.expandKeys]);
|
||||||
|
|
||||||
watch(
|
watch(
|
||||||
@ -313,7 +314,10 @@ watch(
|
|||||||
} else {
|
} else {
|
||||||
hasChecked.value = false;
|
hasChecked.value = false;
|
||||||
}
|
}
|
||||||
emit("update:selectedKeys", tableSelectedKeys.value);
|
if(tableSelectedKeys.value != props.selectedKeys){
|
||||||
|
console.log("初始化赋值触发修改",tableSelectedKeys.value,props.selectedKeys)
|
||||||
|
emit("update:selectedKeys", tableSelectedKeys.value);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
{ deep: true, immediate: true }
|
{ deep: true, immediate: true }
|
||||||
);
|
);
|
||||||
|
@ -101,6 +101,9 @@ function handleTitleClick(node: TreeData) {
|
|||||||
if (!node.isDisabled) {
|
if (!node.isDisabled) {
|
||||||
emit("node-click", node);
|
emit("node-click", node);
|
||||||
}
|
}
|
||||||
|
if(props.showCheckbox){
|
||||||
|
node.isChecked = !node.isChecked
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleRowClick(node: TreeData) {
|
function handleRowClick(node: TreeData) {
|
||||||
@ -182,7 +185,7 @@ const isChildAllSelected = computed(() => {
|
|||||||
:class="{
|
:class="{
|
||||||
'layui-tree-txt': true,
|
'layui-tree-txt': true,
|
||||||
'layui-disabled': node.isDisabled,
|
'layui-disabled': node.isDisabled,
|
||||||
'layui-this': selectedKey === node.id,
|
'layui-this': selectedKey === node.id || node.isChecked,
|
||||||
}"
|
}"
|
||||||
@click.stop="handleTitleClick(node)"
|
@click.stop="handleTitleClick(node)"
|
||||||
>
|
>
|
||||||
|
@ -103,9 +103,13 @@ watch(
|
|||||||
watch(
|
watch(
|
||||||
() => props.checkedKeys,
|
() => props.checkedKeys,
|
||||||
() => {
|
() => {
|
||||||
|
console.log(tree.value)
|
||||||
if (!unWatch.value) {
|
if (!unWatch.value) {
|
||||||
loadNodeList();
|
loadNodeList();
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
deep: true
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -116,9 +120,9 @@ watch(
|
|||||||
const { checkedKeys } = tree.value.getKeys();
|
const { checkedKeys } = tree.value.getKeys();
|
||||||
unWatch.value = true;
|
unWatch.value = true;
|
||||||
emit("update:checkedKeys", checkedKeys);
|
emit("update:checkedKeys", checkedKeys);
|
||||||
setTimeout(() => {
|
nextTick(() => {
|
||||||
unWatch.value = false;
|
unWatch.value = false;
|
||||||
}, 0);
|
});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{ deep: true }
|
{ deep: true }
|
||||||
|
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue
Block a user