From 3b0be895f1d20bbb43e2b0a750a9a5791985b373 Mon Sep 17 00:00:00 2001 From: zhangwenshuai Date: Tue, 15 Dec 2020 17:08:58 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E8=A1=8C=E9=94=81=E5=AE=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/apolloTable/component/Cell.tsx | 36 +++++++++++++---------- 1 file changed, 20 insertions(+), 16 deletions(-) diff --git a/components/apolloTable/component/Cell.tsx b/components/apolloTable/component/Cell.tsx index 54d4d3e..c873ab3 100644 --- a/components/apolloTable/component/Cell.tsx +++ b/components/apolloTable/component/Cell.tsx @@ -60,7 +60,7 @@ const Cell = (props: CellProps) => { } }; - const turnIntoEditStatus = (data:any) => { + const turnIntoEditStatus = (data: any) => { setStatus('edit'); if (typeof onEmitMsg === 'function') { onEmitMsg({ ...data, status: EDIT_STATUS.EDITING }); @@ -80,9 +80,10 @@ const Cell = (props: CellProps) => { return; } let temp: CellDataProps[] = []; - cellData && cellData.map((item: CellDataProps) => { - temp.push({ text: item.text, value: item.value }); - }); + cellData && + cellData.map((item: CellDataProps) => { + temp.push({ text: item.text, value: item.value }); + }); if (temp.length === 0) { temp = emptyModel; } @@ -132,8 +133,8 @@ const Cell = (props: CellProps) => { const { current = 1, pageSize = 20 } = paginationConfig || {}; // 构造序号 const getIndex = () => { - if(typeof showIndex === 'function'){ - return showIndex(props) + if (typeof showIndex === 'function') { + return showIndex(props); } return (current - 1) * pageSize + rowIndex + 1; }; @@ -196,9 +197,7 @@ const Cell = (props: CellProps) => { /> )} - { - renderFirstLeft&&renderFirstLeft({record}) - } + {renderFirstLeft && renderFirstLeft({ record })} ); }; @@ -225,7 +224,7 @@ const Cell = (props: CellProps) => { } else { detailConfig = config[String(columnType)] || config['1']; } - if(Number(columnType)===8){ + if (Number(columnType) === 8) { empty = false; } const DetailComp: any = detailConfig.detailComp; @@ -243,12 +242,17 @@ const Cell = (props: CellProps) => {
{ - // 不可编辑状态 - if (!cellEditable || readOnlyFlag || (dynamicCellConfigDTO && dynamicCellConfigDTO.readonlyFlag)) { + // 不可编辑状态(无编辑权限、列只读、行锁定、单元格只读) + if ( + !cellEditable || + readOnlyFlag || + record.isLocked || + (dynamicCellConfigDTO && dynamicCellConfigDTO.readonlyFlag) + ) { return false; } // 获取当前节点的选中状态 - const dom:any = cellUnit.current; + const dom: any = cellUnit.current; let selected = false; if (dom && dom.getAttribute('data-selected-cell')) { selected = dom.getAttribute('data-selected-cell') === '1'; @@ -264,9 +268,9 @@ const Cell = (props: CellProps) => { // 否则进入选中状态 if (dom) { // 先清除所有dom的选中状态及样式 - const doms:any = document.querySelectorAll(`.cellUnit.table_${tableId}`); + const doms: any = document.querySelectorAll(`.cellUnit.table_${tableId}`); if (doms) { - doms.forEach((item:any) => { + doms.forEach((item: any) => { item.setAttribute('data-selected-cell', '0'); item.classList.remove(s.selected); }); @@ -403,7 +407,7 @@ const Cell = (props: CellProps) => { onMouseEnter={onMouseEnter} onMouseLeave={onMouseLeave} > - {columnIndex === 0 && position!=='right' && renderFirst()} + {columnIndex === 0 && position !== 'right' && renderFirst()}