From 03a22ec6f9ad7303d10b4c65bb5bc6fa5cbd448a Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期六, 22 十月 2022 23:21:42 +0800 Subject: [PATCH] 2022-10-22 --- src/menu/components/table/base-table/index.jsx | 69 +++++++++++++++++++++++++++++++++- 1 files changed, 66 insertions(+), 3 deletions(-) diff --git a/src/menu/components/table/base-table/index.jsx b/src/menu/components/table/base-table/index.jsx index 9620ec9..f4a90c1 100644 --- a/src/menu/components/table/base-table/index.jsx +++ b/src/menu/components/table/base-table/index.jsx @@ -6,6 +6,7 @@ import asyncComponent from '@/utils/asyncComponent' import asyncIconComponent from '@/utils/asyncIconComponent' +import { getTables } from '@/utils/utils-custom.js' import MKEmitter from '@/utils/events.js' import getWrapForm from './options' import Utils from '@/utils/utils.js' @@ -38,6 +39,7 @@ let _card = { uuid: card.uuid, type: card.type, + name: card.name || '', format: 'array', // 缁勪欢灞炴�� - 鏁版嵁鏍煎紡 pageable: true, // 缁勪欢灞炴�� - 鏄惁鍙垎椤� switchable: true, // 缁勪欢灞炴�� - 鏁版嵁鏄惁鍙垏鎹� @@ -53,7 +55,7 @@ subtype: card.subtype, setting: { interType: 'system' }, wrap: { bordered: 'true', tableType: 'checkbox', show: 'true' }, - style: { marginLeft: '8px', marginRight: '8px', marginTop: '8px', marginBottom: '8px' }, + style: {}, headerStyle: { fontSize: '16px', borderBottomWidth: '1px', borderBottomColor: '#e8e8e8' }, columns: [], cols: [ @@ -105,7 +107,6 @@ item.cols = item.cols.filter(a => !a.origin) delete item.isNew - this.setState({card: item}, () => { MKEmitter.emit('revert') }) } } @@ -148,6 +149,10 @@ card.errors.push({ level: 0, detail: '涓婚敭宸插け鏁堬紒'}) } else if (!card.setting.supModule) { card.errors.push({ level: 0, detail: '鏈缃笂绾х粍浠讹紒'}) + } + + if (card.errors.length === 0) { + card.$tables = getTables(card) } card.action.forEach(cell => { @@ -307,6 +312,64 @@ this.updateComponent({...card, wrap: res}) } + updatecolumn = (config) => { + config.columns = [] + config.absFields = [] + config.cols.forEach(col => { + if (!col.field) return + if (['text', 'picture', 'textarea'].includes(col.type)) { + config.columns.push({ + datatype: `Nvarchar(${col.fieldlength || 50})`, + field: col.field, + fieldlength: col.fieldlength || 50, + label: col.label, + type: 'text', + uuid: col.uuid + }) + } else if (col.type === 'link') { + config.columns.push({ + datatype: `Nvarchar(${col.fieldlength || 50})`, + field: col.field, + fieldlength: col.fieldlength || 50, + label: col.label, + type: 'text', + uuid: col.uuid + }) + if (col.nameField) { + config.columns.push({ + datatype: `Nvarchar(${col.fieldlength || 50})`, + field: col.nameField, + fieldlength: col.fieldlength || 50, + label: col.label + '(鍚嶇О)', + type: 'text', + uuid: col.uuid + 'name' + }) + } + } else if (col.type === 'number') { + config.columns.push({ + datatype: `Decimal(18,${col.decimal || 0})`, + field: col.field, + decimal: col.decimal || 0, + label: col.label, + type: 'number', + uuid: col.uuid + }) + + if (col.format === 'abs') { + config.absFields.push(col.field) + } + } + }) + + if (config.absFields.length) { + config.absFields = Array.from(new Set(config.absFields)) + } else { + config.absFields = null + } + + this.updateComponent(config) + } + render() { const { card } = this.state let options = ['action', 'search', 'form', 'cols'] @@ -328,7 +391,7 @@ </Popover> <SearchComponent config={card} updatesearch={this.updateComponent}/> <ActionComponent config={card} setSubConfig={this.setSubConfig} updateaction={this.updateComponent}/> - <ColumnComponent config={card} updatecolumn={this.updateComponent}/> + <ColumnComponent config={card} updatecolumn={this.updatecolumn}/> </div> ) } -- Gitblit v1.8.0