From 49f09cc6f8ff8c30a75ed1a9d6f510b69b73962a Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期二, 12 十二月 2023 21:05:37 +0800 Subject: [PATCH] 2023-12-12 --- src/menu/components/table/base-table/index.jsx | 73 +++++++++++++++++------------------- 1 files changed, 35 insertions(+), 38 deletions(-) diff --git a/src/menu/components/table/base-table/index.jsx b/src/menu/components/table/base-table/index.jsx index 70765a7..95759e2 100644 --- a/src/menu/components/table/base-table/index.jsx +++ b/src/menu/components/table/base-table/index.jsx @@ -99,39 +99,6 @@ MKEmitter.removeListener('completeSave', this.completeSave) } - // updateFix = (card) => { - // let fixs = {} - - // card.cols.forEach(col => { - // if (!col.field) return - // if (col.postfix || col.prefix) { - // fixs[col.field] = col - // } - // }) - - // card.cols.forEach(col => { - // if (col.type === 'custom') { - // col.elements.forEach(cell => { - // if (cell.datatype === 'dynamic') { - // cell.height = '' - // cell.innerHeight = 'auto' - - // if (fixs[cell.field]) { - // if (!cell.prefix && fixs[cell.field].prefix) { - // cell.prefix = fixs[cell.field].prefix - // } - // if (!cell.postfix && fixs[cell.field].postfix) { - // cell.postfix = fixs[cell.field].postfix - // } - // } - // } - // }) - // } - // }) - - // return card - // } - completeSave = () => { const { card } = this.state @@ -142,7 +109,9 @@ item.cols = item.cols.filter(a => !a.origin) delete item.isNew - this.setState({card: item}, () => { MKEmitter.emit('revert') }) + this.setState({card: null}, () => { + this.setState({card: item}) + }) } } @@ -253,8 +222,13 @@ let _actions = [...action] cols.forEach(col => { - if (col.type !== 'action') return - _actions.push(...col.elements) + if (col.type === 'custom') { + col.elements.forEach(cell => { + if (cell.eleType !== 'button') return + + _actions.push(cell) + }) + } }) return getWrapForm(wrap, _actions, columns) @@ -273,6 +247,8 @@ res.drawerPlacement = card.wrap.drawerPlacement || 'right' res.searchRatio = card.wrap.searchRatio || 6 res.searchLwidth = card.wrap.searchLwidth !== undefined ? card.wrap.searchLwidth : 33.3 + res.borderRadius = card.wrap.borderRadius || 0 + res.resetContrl = card.wrap.resetContrl || 'init' this.updateComponent({...card, wrap: res}) } @@ -283,12 +259,23 @@ config.cols.forEach(col => { if (!col.field) return if (['text', 'picture', 'video', 'textarea'].includes(col.type)) { + let datatype = `Nvarchar(${col.fieldlength || 50})` + let type = 'text' + + if (col.type === 'text') { + if (col.textFormat === 'YYYY-MM-DD') { + datatype = 'date' + } else if (col.textFormat === 'YYYY-MM-DD HH:mm:ss') { + datatype = 'datetime' + } + } + config.columns.push({ - datatype: `Nvarchar(${col.fieldlength || 50})`, + datatype: datatype, field: col.field, fieldlength: col.fieldlength || 50, label: col.label, - type: 'text', + type: type, uuid: col.uuid }) } else if (col.type === 'link') { @@ -332,6 +319,14 @@ config.absFields = null } + if (!config.setting.primaryKey && config.columns.length > 0) { + config.columns.forEach(col => { + if (col.field.toLowerCase() === 'id') { + config.setting.primaryKey = col.field + } + }) + } + this.updateComponent(config) } @@ -346,6 +341,8 @@ const { card } = this.state let options = ['action', 'search', 'form', 'cols'] + if (!card) return null + return ( <div className="menu-base-table-edit-box" style={card.style} id={card.uuid}> <Popover overlayClassName="mk-popover-control-wrap" mouseLeaveDelay={0.2} mouseEnterDelay={0.2} content={ -- Gitblit v1.8.0