Commit 07f4fb30 authored by 彭俊龙's avatar 彭俊龙

feat:数据字典下拉框支持显示key存储value

parent f4a7438d
{
"name": "panda-xform",
"version": "6.10.99",
"description": "6.10.99 关联表单行内支持数据复制、多选支持搜索",
"version": "6.11.08",
"description": "6.11.08 关联表单行内支持数据复制、多选支持搜索",
"keywords": [
"panda-xform"
],
......
......@@ -232,7 +232,12 @@ const ValueEdit = (props) => {
}
if (widget === 'AccountSelector') {
return <AccountSelectorCell {...props} />
return (
<Tooltip title={value}>
<></>
<AccountSelectorCell {...props} />
</Tooltip>
)
}
const renderWidget = (w) => {
if (['CheckBox', 'ComboBox', 'RadioButton'].includes(w) && sourceType === '手动输入') {
......@@ -395,7 +400,8 @@ const ValueEdit = (props) => {
return (<>
<Tooltip title={value}>
<Tooltip title={(widget === 'PersonSelector' && isStoreID) ? pullDown.find(v => Number(v.value) === Number(value))?.userName : value}>
<></>
{ renderWidget(widget) }
</Tooltip>
......
import React, { useMemo, useState, forwardRef, useImperativeHandle, useRef, useEffect } from 'react'
import { Table, Button, Popconfirm, Input, Space, Tag, Popover, Checkbox, Form, message } from 'antd'
import { Table, Button, Popconfirm, Input, Space, Tag, Popover, Checkbox, Form, message, Tooltip } from 'antd'
import { TweenOneGroup } from 'rc-tween-one'
import styles from './index.less'
import { SearchOutlined, FormOutlined, CopyOutlined } from '@ant-design/icons'
......@@ -38,7 +38,6 @@ const TablePack = (props, ref) => {
const [checks, setChecks] = useState([])
const searchInput = useRef(null)
const [form] = Form.useForm()
console.log(dataSource, props, 'dataSource');
const filtered = useMemo(() => {
let array = []
if (isObject(filteredInfo)) {
......@@ -292,16 +291,36 @@ const TablePack = (props, ref) => {
)
} else {
if (['FileUpload'].includes(widget)) {
return <FileView {...props} />
return (
<Tooltip title={props.value}>
<></>
<FileView {...props} />
</Tooltip>
)
}
if (['Coordinate', 'Device', 'DrawPath', 'DrawArea'].includes(widget)) {
return <CoordView {...props} />
return (
<Tooltip title={props.value}>
<></>
<CoordView {...props} />
</Tooltip>
)
}
if (['RadioButton', 'CheckBox', 'ComboBox'].includes(widget)) {
return <SelectView {...props} />
return (
<Tooltip title={props.value}>
<></>
<SelectView {...props} />
</Tooltip>
)
}
if (['DateTime'].includes(widget)) {
return <DateView {...props} />
return (
<Tooltip title={props.value}>
<></>
<DateView {...props} />
</Tooltip>
)
}
// if (['NumberInput'].includes(widget)) {
// return <NumberView {...props} />
......@@ -414,6 +433,15 @@ const TablePack = (props, ref) => {
</div>
)
const copyTextFallback = (text) => {
const textArea = document.createElement("textarea");
textArea.value = text;
document.body.appendChild(textArea);
textArea.select();
document.execCommand("copy");
document.body.removeChild(textArea);
};
const columns = useMemo(() => {
let columns = [
{
......@@ -493,10 +521,20 @@ const TablePack = (props, ref) => {
style={{ padding: '0 7px' }}
onClick={() => {
let arr = [];
for (let key in r) {
arr.push(`${r[key]}`)
if(columns.length > 1){
const dataIndexs = columns.filter(v=> v.dataIndex).map(v => v.dataIndex)
const ks = Object.keys(r)
if(ks.includes('r')){
arr.push(`${r['r']}`)//序号
}
dataIndexs.forEach(v=> {
if(ks.includes(v)){
arr.push(`${r[v]}`)
}
})
}
navigator.clipboard.writeText(arr.join('\t'));
let str = arr.join('\t');
copyTextFallback(str)
message.success("数据已复制");
}}
>
......
......@@ -1021,6 +1021,14 @@ const baseWidgets = [
widget: 'FieldName',
dependencies: ['sourceType', 'tableName'],
},
saveVal: {
title: '存储值',
type: 'boolean',
hidden: '{{formData.sourceType !== "数据字典"}}',
description: '勾选后可数据字典将显示key存储value',
widget: 'checkbox',
default: false,
},
isMySite: {
title: '仅显示本人所属的站点',
default: false,
......
......@@ -22,6 +22,7 @@ const ComboBox = (props) => {
isMultiple,
isEdit,
isMySite,
saveVal,
isSearch,
isStoreID,
color,
......@@ -31,11 +32,16 @@ const ComboBox = (props) => {
const [tableData, setTableData] = useState([])
const [site, setSite] = useState([])
useEffect(() => {
console.log(props, 'propssssss')
if (addons) {
addons.setValue(addons.dataPath, presetValue || '')
if (sourceType === '站点') {
getStation(presetValue)
}
if(sourceType === '数据字典' && dictionary && saveVal){
getDictionaryItemList(dictionary)
}else{
addons.setValue(addons.dataPath, presetValue || '')
}
} else {
onChange(presetValue || '')
}
......@@ -54,7 +60,7 @@ const ComboBox = (props) => {
case '手动输入':
return Array.isArray(options) ? options : []
case '数据字典':
return Array.isArray(dictionaryList) ? dictionaryList.map(v => v.nodeName) : []
return Array.isArray(dictionaryList) ? saveVal ? dictionaryList : dictionaryList.map(v=> v.nodeName) : []
case '表数据':
return Array.isArray(tableData) ? tableData : []
case '站点':
......@@ -77,8 +83,12 @@ const ComboBox = (props) => {
</Option>
)
} else {
if(sourceType === '数据字典' && saveVal){
children.push(<Option key={v} value={v.nodeValue}>{v.nodeName}</Option>)
}else{
children.push(<Option key={v} value={v}>{v}</Option>)
}
}
})
}
return children
......@@ -136,12 +146,31 @@ const ComboBox = (props) => {
}
}
const getDictionaryItemList = async (dictionary)=>{
if (!dictionary) {
return message.error('请选择数据字典!')
}
const { data } = await GetSelectItemList({ nodeName: dictionary })
if (Array.isArray(data)) {
setDictionaryList(data)
if(saveVal && presetValue){
const d = data.find(v=> v.nodeName === presetValue)
if(d){
addons.setValue(addons.dataPath, d.nodeValue)
}
}
}
}
const onFocus = async () => {
if (addons) {
if (sourceType === '数据字典') {
if (!dictionary) {
return message.error('请选择数据字典!')
}
if(dictionaryList.length > 0){
return;
}
const { data } = await GetSelectItemList({ nodeName: dictionary })
if (Array.isArray(data)) {
setDictionaryList(data)
......
......@@ -10,7 +10,6 @@ const Coding = (props) => {
const prefixCls = getPrefixCls('pandaXform')
const { value, onChange, addons, schema } = props
const { disabled, prefixion, codingType, presetValue, required, placeholder } = schema
console.log(props, 'propspropspropspropsprops');
const inputChange = (e) => {
onChange(e.target.value)
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment