From 73083e2eef00c34c2db62ddea12baa6e44ba1dd6 Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期四, 08 二月 2024 00:31:07 +0800 Subject: [PATCH] 2024-02-08 --- src/tabviews/zshare/mutilform/mkPopSelect/index.jsx | 18 +++++++-- src/tabviews/zshare/mutilform/index.jsx | 6 +++ src/tabviews/custom/components/table/edit-table/normalTable/mkPopSelect/index.jsx | 13 ++++-- src/menu/components/table/edit-table/columns/editColumn/index.jsx | 2 src/menu/components/table/edit-table/columns/editColumn/formconfig.jsx | 9 ++++ src/tabviews/custom/components/table/edit-table/normalTable/index.jsx | 22 ++++++++++- 6 files changed, 59 insertions(+), 11 deletions(-) diff --git a/src/menu/components/table/edit-table/columns/editColumn/formconfig.jsx b/src/menu/components/table/edit-table/columns/editColumn/formconfig.jsx index 48a01c1..5a1a212 100644 --- a/src/menu/components/table/edit-table/columns/editColumn/formconfig.jsx +++ b/src/menu/components/table/edit-table/columns/editColumn/formconfig.jsx @@ -441,6 +441,15 @@ }, { type: 'select', + key: 'showField', + label: '鏄剧ず瀛楁', + initVal: card.showField || '', + tooltip: '鐢ㄤ簬鎺у埗鍗曞厓鏍间腑鐨勬樉绀哄唴瀹广��', + required: false, + options: 'columns' + }, + { + type: 'select', key: 'controlField', label: '绂佺敤瀛楁', initVal: card.controlField || '', diff --git a/src/menu/components/table/edit-table/columns/editColumn/index.jsx b/src/menu/components/table/edit-table/columns/editColumn/index.jsx index 7458ba3..4b74dca 100644 --- a/src/menu/components/table/edit-table/columns/editColumn/index.jsx +++ b/src/menu/components/table/edit-table/columns/editColumn/index.jsx @@ -78,7 +78,7 @@ } else if (this.record.editType === 'date') { _options.push('required', 'precision', 'enter', 'declareType') } else if (this.record.editType === 'popSelect') { - _options.push('required', 'enter', 'linkSubField', 'columns', 'dataSource', 'primaryKey', 'order', 'controlField', 'searchKey', 'popWidth', 'laypage', 'cache', 'onload') + _options.push('required', 'enter', 'linkSubField', 'columns', 'dataSource', 'primaryKey', 'order', 'showField', 'controlField', 'searchKey', 'popWidth', 'laypage', 'cache', 'onload') } else if (this.record.editType === 'select') { _options.push('required', 'enter', 'resourceType', 'linkSubField', 'dropdown') diff --git a/src/tabviews/custom/components/table/edit-table/normalTable/index.jsx b/src/tabviews/custom/components/table/edit-table/normalTable/index.jsx index 1de493a..0272b1c 100644 --- a/src/tabviews/custom/components/table/edit-table/normalTable/index.jsx +++ b/src/tabviews/custom/components/table/edit-table/normalTable/index.jsx @@ -752,6 +752,10 @@ } else if (content === config.closeVal) { content = config.closeText } + } else if (col.editType === 'popSelect') { + if (col.showField) { + content = record[col.showField] || content + } } if (content !== '') { @@ -809,8 +813,13 @@ <MkDatePicker config={col} lineId={record.$$uuid} defaultValue={_value || null} autoFocus={true} onChange={this.onColChange} onBlur={() => this.setState({editing: false})}/> </td>) } else if (col.editType === 'popSelect') { + let showValue = '' + if (col.showField) { + showValue = record[col.showField] || '' + } + return (<td onClick={(e) => e.stopPropagation()} className="editing_table_cell"> - <MKPopSelect config={col} lineId={record.$$uuid} defaultValue={_value} BID={record.$$BID} autoFocus={true} onChange={this.onColChange} onBlur={() => this.setState({editing: false})}/> + <MKPopSelect config={col} lineId={record.$$uuid} defaultValue={_value} showValue={showValue} BID={record.$$BID} autoFocus={true} onChange={this.onColChange} onBlur={() => this.setState({editing: false})}/> </td>) } else { return (<td onClick={(e) => e.stopPropagation()} className="editing_table_cell"> @@ -1056,8 +1065,13 @@ <MkDatePicker config={col} lineId={record.$$uuid} defaultValue={_value || null} autoFocus={false} onChange={this.onColChange}/> ) } else if (col.editType === 'popSelect') { + let showValue = '' + if (col.showField) { + showValue = record[col.showField] || '' + } + children = ( - <MKPopSelect config={col} lineId={record.$$uuid} defaultValue={_value} BID={record.$$BID} autoFocus={false} onChange={this.onColChange}/> + <MKPopSelect config={col} lineId={record.$$uuid} defaultValue={_value} showValue={showValue} BID={record.$$BID} autoFocus={false} onChange={this.onColChange}/> ) } else { children = ( @@ -1078,6 +1092,10 @@ } else if (content === config.closeVal) { content = config.closeText } + } else if (col.editType === 'popSelect') { + if (col.showField) { + content = record[col.showField] || content + } } if (content !== '') { diff --git a/src/tabviews/custom/components/table/edit-table/normalTable/mkPopSelect/index.jsx b/src/tabviews/custom/components/table/edit-table/normalTable/mkPopSelect/index.jsx index 29e7463..d74157b 100644 --- a/src/tabviews/custom/components/table/edit-table/normalTable/mkPopSelect/index.jsx +++ b/src/tabviews/custom/components/table/edit-table/normalTable/mkPopSelect/index.jsx @@ -234,6 +234,7 @@ this.state = { value: props.defaultValue, + showValue: props.showValue, visible: false } } @@ -275,6 +276,10 @@ const { config, lineId } = this.props let values = {[config.field]: record.$$uuid} + let showValue = '' + if (config.showField) { + showValue = record[config.showField] || '' + } if (config.linkSubField) { config.linkSubField.forEach((m, i) => { @@ -284,7 +289,7 @@ this.props.onChange(values, record.$$uuid) - this.setState({visible: false, value: record.$$uuid}) + this.setState({visible: false, value: record.$$uuid, showValue}) if (config.$ctrl) { MKEmitter.emit('colBlur' + config.tableId, lineId, config.uuid) @@ -329,7 +334,7 @@ } this.props.onChange(values, '') - this.setState({value: ''}) + this.setState({value: '', showValue: ''}) if (config.$ctrl) { MKEmitter.emit('colBlur' + config.tableId, lineId, config.uuid) @@ -350,12 +355,12 @@ render() { const { autoFocus, BID, lineId, config } = this.props - const { value, visible } = this.state + const { showValue, value, visible } = this.state return <> {autoFocus ? <div className="mk-pop-select-mask" onClick={this.trigger}></div> : null} <div className="mk-pop-select-wrap" onClick={this.trigger}> - {value} + {showValue || value} {value && !autoFocus ? <CloseCircleFilled onClick={this.clear} /> : null} <TableOutlined onClick={this.trigger}/> </div> diff --git a/src/tabviews/zshare/mutilform/index.jsx b/src/tabviews/zshare/mutilform/index.jsx index 9ab8e55..8c3ca5e 100644 --- a/src/tabviews/zshare/mutilform/index.jsx +++ b/src/tabviews/zshare/mutilform/index.jsx @@ -262,6 +262,12 @@ } else { newval = item.closeVal } + } else if (item.type === 'popSelect') { + if (newval && newval !== '$empty') { + item.showValue = data[item.showField.toLowerCase()] || '' + } else { + item.showValue = '' + } } if (newval !== '$empty') { diff --git a/src/tabviews/zshare/mutilform/mkPopSelect/index.jsx b/src/tabviews/zshare/mutilform/mkPopSelect/index.jsx index a0d02c5..30ef195 100644 --- a/src/tabviews/zshare/mutilform/mkPopSelect/index.jsx +++ b/src/tabviews/zshare/mutilform/mkPopSelect/index.jsx @@ -80,6 +80,7 @@ options: [], columns, value, + showValue: config.showValue, placeholder, arr_field: arrfield.join(','), searchKey: '', @@ -188,8 +189,17 @@ return item }) + + let showValue = this.state.showValue + + if (showValue) { + if (options.findIndex(item => this.state.value === item.$$uuid) > -1) { + showValue = '' + } + } this.setState({ + showValue, options: options, total: result.total || 0, loading: false @@ -261,7 +271,7 @@ } this.props.onChange(val, other) - this.setState({value: val}, () => { + this.setState({value: val, showValue: ''}, () => { if (config.enter === 'tab') { MKEmitter.emit('mkFC', 'focus', config.tabUuid) } else if (config.enter === 'sub') { @@ -312,14 +322,14 @@ } render() { - const { value, config, options, visible, loading, total, pageIndex, pageSize, columns, placeholder } = this.state + const { value, showValue, config, options, visible, loading, total, pageIndex, pageSize, columns, placeholder, searchKey } = this.state return <> <Select className="mk-pop-select" showSearch={!!config.searchKey} allowClear - value={value} + value={showValue || value} onSearch={(val) => val && this.searchOption(val)} filterOption={false} onChange={(val) => this.selectChange(val === undefined ? '' : val)} @@ -342,7 +352,7 @@ onCancel={() => this.setState({visible: false})} destroyOnClose > - {config.searchKey ? <Search placeholder={placeholder} onSearch={this.searchOption} enterButton /> : null} + {config.searchKey ? <Search placeholder={placeholder} defaultValue={searchKey} onSearch={this.searchOption} enterButton /> : null} <Table rowKey="$$uuid" bordered={true} -- Gitblit v1.8.0