Vanessa 2023-07-14 00:41:49 +08:00
parent 7f097f3b99
commit 5546bb75b8

View File

@ -355,7 +355,13 @@ export const addSelectColAndCell = (protyle: IProtyle, data: IAV, options: {
}, currentElement: HTMLElement, menuElement: HTMLElement) => {
const rowID = options.cellElement.parentElement.dataset.id;
const colId = options.cellElement.dataset.colId;
const cellId = options.cellElement.dataset.id;
let cellIndex = 0;
Array.from(options.cellElement.parentElement.querySelectorAll(".av__cell")).find((item: HTMLElement, index) => {
if (item.dataset.id === options.cellElement.dataset.id) {
cellIndex = index;
return true;
}
})
let colData: IAVColumn;
data.view.columns.find((item: IAVColumn) => {
if (item.id === colId) {
@ -369,38 +375,26 @@ export const addSelectColAndCell = (protyle: IProtyle, data: IAV, options: {
let cellData: IAVCell;
data.view.rows.find(row => {
if (row.id === rowID) {
row.cells.find(cell => {
if (cell.id === cellId) {
cellData = cell;
if (!cellData.value.mSelect) {
cellData.value.mSelect = [];
}
return true;
}
});
cellData = row.cells[cellIndex];
// 为空时 cellId 每次请求都不一致
cellData.id = options.cellElement.dataset.id;
if (!cellData.value) {
cellData.value = {mSelect:[]} as IAVCellValue;
}
return true;
}
});
if (!cellData) {
cellData = {
color: "",
bgColor: "",
id: Lute.NewNodeID(),
value: genCellValue(colData.type, ""),
valueType: colData.type
};
} else {
let hasSelected = false;
cellData.value.mSelect.find((item) => {
if (item.content === currentElement.dataset.name) {
hasSelected = true;
return true;
}
});
if (hasSelected) {
menuElement.querySelector("input").focus();
return;
let hasSelected = false;
cellData.value.mSelect.find((item) => {
if (item.content === currentElement.dataset.name) {
hasSelected = true;
return true;
}
});
if (hasSelected) {
menuElement.querySelector("input").focus();
return;
}
const oldValue = Object.assign([], cellData.value.mSelect);
@ -428,7 +422,7 @@ export const addSelectColAndCell = (protyle: IProtyle, data: IAV, options: {
data: colData.options
}, {
action: "updateAttrViewCell",
id: cellId,
id: cellData.id,
keyID: colId,
rowID,
avID: data.id,
@ -442,14 +436,14 @@ export const addSelectColAndCell = (protyle: IProtyle, data: IAV, options: {
} else {
transaction(protyle, [{
action: "updateAttrViewCell",
id: cellId,
id: cellData.id,
keyID: colId,
rowID,
avID: data.id,
data: cellData.value
}], [{
action: "updateAttrViewCell",
id: cellId,
id: cellData.id,
keyID: colId,
rowID,
avID: data.id,