Commit 6b445141 authored by 田翔's avatar 田翔

fix: 关联表单可编辑增加数值与日期形态

parent 3fcf458a
{ {
"name": "panda-xform", "name": "panda-xform",
"version": "5.0.7", "version": "5.0.8",
"description": "5.0.7 关联表单增加可编辑状态与台账导入", "description": "5.0.8 关联表单可编辑增加数值与日期形态",
"keywords": [ "keywords": [
"panda-xform" "panda-xform"
], ],
......
import React from 'react'
import { Input, InputNumber, DatePicker } from 'antd'
import locale from 'antd/lib/date-picker/locale/zh_CN'
import moment from 'moment'
const ValueEdit = (props) => {
const {
onChange,
value,
disabled,
placeholder,
widget,
format,
min,
max,
formatter,
} = props
if (widget === 'DateTime') {
const isValid = value ? moment(value)._isValid : false
const timeOtions = format === 'dateTime' ?
{
showTime: {
minuteStep: 5,
format: 'HH:mm'
},
format: 'YYYY-MM-DD HH:mm'
}
:
{
picker: format,
showTime: false
}
return (
<DatePicker
disabled={disabled}
placeholder={disabled ? (placeholder || '') : (placeholder || '点击选择日期')}
value={isValid ? moment(value) : null}
showNow
{...timeOtions}
style={{ width: '100%' }}
locale={locale}
onChange={(date) => {
if (date && date._d) {
onChange(moment(date._d).format('YYYY-MM-DD HH:mm:ss'))
} else {
onChange('')
}
}}
/>
)
}
if (widget === 'NumberInput') {
return (
<InputNumber
min={min || Number.MIN_SAFE_INTEGER}
max={max || Number.MAX_SAFE_INTEGER}
step={(formatter === '${百分比}' && isStoreFormatter) ? 0.01 : 1}
placeholder={disabled ? (placeholder || '') : (placeholder || '请输入内容')}
disabled={disabled}
value={value === '' ? null : Number(value)}
onChange={(value) => {
if (value !== null) {
onChange(`${value}`)
} else {
onChange('')
}
}}
style={{ width: '100%' }}
/>
)
}
return (
<Input
disabled={disabled}
onChange={(e) => onChange(e.target.value)}
value={value}
/>
)
}
export default ValueEdit
\ No newline at end of file
...@@ -8,6 +8,7 @@ import ResizeableTitle from './components/ResizeableTitle' ...@@ -8,6 +8,7 @@ import ResizeableTitle from './components/ResizeableTitle'
import FileView from './components/FileView' import FileView from './components/FileView'
import CoordView from './components/CoordView' import CoordView from './components/CoordView'
import SelectView from './components/SelectView' import SelectView from './components/SelectView'
import ValueEdit from './components/ValueEdit'
import IconPack from '../../../components/IconPack' import IconPack from '../../../components/IconPack'
import { isObject, isArray, getFieldInfo } from '../../../../utils' import { isObject, isArray, getFieldInfo } from '../../../../utils'
...@@ -228,13 +229,17 @@ const TablePack = (props, ref) => { ...@@ -228,13 +229,17 @@ const TablePack = (props, ref) => {
}, },
}), }),
render: (value, record) => { render: (value, record) => {
if (isEdit) { let props = { ...json[fieldName], value }
if (isEdit && !notUse?.includes('edit')) {
return ( return (
<Input onChange={(e) => btnsClick({ type: '变化', row: { ...record, [fieldName]: e.target.value } })} value={value} /> <ValueEdit
{...props}
onChange={(value) => btnsClick({ type: '变化', row: { ...record, [fieldName]: value } })}
value={value}
/>
) )
} else { } else {
let props = { ...json[fieldName], value } if (['FileUpload'].includes(widget)) {
if (widget === 'FileUpload') {
return <FileView {...props} /> return <FileView {...props} />
} }
if (['Coordinate', 'Device', 'DrawPath', 'DrawArea'].includes(widget)) { if (['Coordinate', 'Device', 'DrawPath', 'DrawArea'].includes(widget)) {
...@@ -251,17 +256,25 @@ const TablePack = (props, ref) => { ...@@ -251,17 +256,25 @@ const TablePack = (props, ref) => {
const btns = useMemo(() => { const btns = useMemo(() => {
let array = [] let array = []
if (!notUse?.includes('read')) { //表格可编辑
array.push({ title: '详情', icon: <IconPack.XiangQing />, }) if (isEdit) {
} if (!notUse?.includes('del')) {
if (!notUse?.includes('edit')) { array.push({ title: '删除', icon: <IconPack.ShanChu /> })
array.push({ title: '编辑', icon: <IconPack.BianJi /> }) }
} } else {
if (!notUse?.includes('del')) { if (!notUse?.includes('read')) {
array.push({ title: '删除', icon: <IconPack.ShanChu /> }) array.push({ title: '详情', icon: <IconPack.XiangQing />, })
}
if (!notUse?.includes('edit')) {
array.push({ title: '编辑', icon: <IconPack.BianJi /> })
}
if (!notUse?.includes('del')) {
array.push({ title: '删除', icon: <IconPack.ShanChu /> })
}
} }
return array return array
}, [notUse, parent]) }, [notUse, isEdit])
const checkChange = (values) => { const checkChange = (values) => {
setChecks(values) setChecks(values)
...@@ -335,7 +348,7 @@ const TablePack = (props, ref) => { ...@@ -335,7 +348,7 @@ const TablePack = (props, ref) => {
if (btns.length) { if (btns.length) {
columns.push( columns.push(
{ {
title: isEdit ? '操作' : ( title: (
<div className={styles.operation}> <div className={styles.operation}>
<span>操作</span> <span>操作</span>
<span className={styles.operationSpan}> <span className={styles.operationSpan}>
...@@ -362,7 +375,7 @@ const TablePack = (props, ref) => { ...@@ -362,7 +375,7 @@ const TablePack = (props, ref) => {
</span> </span>
</div> </div>
), ),
width: isEdit ? 75 : btns.length * 35 + 30, width: btns.length * 35 + 30,
align: 'center', align: 'center',
filteredValue: null, filteredValue: null,
fixed: 'right', fixed: 'right',
...@@ -370,7 +383,7 @@ const TablePack = (props, ref) => { ...@@ -370,7 +383,7 @@ const TablePack = (props, ref) => {
return ( return (
<div style={{ display: 'flex', justifyContent: 'center' }}> <div style={{ display: 'flex', justifyContent: 'center' }}>
{ {
(isEdit ? [{ title: '删除', icon: <IconPack.ShanChu /> }] : btns).map(v => { btns.map(v => {
if (v.title === '删除') { if (v.title === '删除') {
return ( return (
<Popconfirm <Popconfirm
...@@ -412,7 +425,7 @@ const TablePack = (props, ref) => { ...@@ -412,7 +425,7 @@ const TablePack = (props, ref) => {
return fileColumns return fileColumns
} }
return columns return columns
}, [parent, btns, dataSource, fileColumns, checks, open, isEdit]) }, [parent, btns, dataSource, fileColumns, checks, open])
const onChange = (page, filters, sorter) => { const onChange = (page, filters, sorter) => {
setFilteredInfo(filters) setFilteredInfo(filters)
...@@ -434,6 +447,8 @@ const TablePack = (props, ref) => { ...@@ -434,6 +447,8 @@ const TablePack = (props, ref) => {
tableChange?.({}, filtered, sortedInfo) tableChange?.({}, filtered, sortedInfo)
} }
console.log('props', props, btns, columns)
return ( return (
<div className={styles.tablePack} style={{ paddingTop: filtered.length ? '30px' : '10px' }}> <div className={styles.tablePack} style={{ paddingTop: filtered.length ? '30px' : '10px' }}>
{ {
......
...@@ -138,9 +138,9 @@ const RelationForm = (props) => { ...@@ -138,9 +138,9 @@ const RelationForm = (props) => {
} }
const deleteTableInfo = (r) => { const deleteTableInfo = (r) => {
let listItem = { type: 'delete', accountTable: accountName, ID: r.ID, values: getItem('delete', r) } let listItem = { type: 'delete', accountTable: accountName, ID: r?.ID, values: getItem('delete', r) }
let relationForm = addons.getValue('relationForm') || { configs: [], data: [] } let relationForm = addons.getValue('relationForm') || { configs: [], data: [] }
if (r.ID.includes('前端ID')) { if (r?.ID?.includes('前端ID')) {
let list = relationForm.data.filter(v => v.ID !== r.ID) let list = relationForm.data.filter(v => v.ID !== r.ID)
addons.setValue('relationForm', { ...relationForm, data: list }) addons.setValue('relationForm', { ...relationForm, data: list })
} else { } else {
...@@ -281,13 +281,16 @@ const RelationForm = (props) => { ...@@ -281,13 +281,16 @@ const RelationForm = (props) => {
let formValue = [] let formValue = []
let field = config?.accountFieids?.filter(v => v.webDisplay).map(v => v.fieldName) let field = config?.accountFieids?.filter(v => v.webDisplay).map(v => v.fieldName)
field.forEach(v => { field.forEach(v => {
formValue.push({ fieldName: v, fieldValue: row[v] }) formValue.push({ fieldName: v, fieldValue: row[v] || '' })
}) })
let itemData = { type, accountTable: accountName, ID: row.ID, values: formValue } let itemData = { type, accountTable: accountName, ID: row.ID, values: formValue }
let relationForm = addons.getValue('relationForm') || { configs: [], data: [] } let relationForm = addons.getValue('relationForm') || { configs: [], data: [] }
let listArray = relationForm.data.filter(v => v.ID !== itemData.ID) let listArray = relationForm.data.filter(v => v.ID !== itemData.ID)
listArray.push(itemData) listArray.push(itemData)
addons.setValue('relationForm', { ...relationForm, data: listArray }) addons.setValue('relationForm', { ...relationForm, data: listArray })
setTimeout(() => {
onChange(value && value.includes(' ') ? `${array.length}` : `${array.length} `)
}, 0)
} else { } else {
rowClick(type, row) rowClick(type, row)
} }
...@@ -323,6 +326,9 @@ const RelationForm = (props) => { ...@@ -323,6 +326,9 @@ const RelationForm = (props) => {
let relationForm = addons.getValue('relationForm') || { configs: [], data: [] } let relationForm = addons.getValue('relationForm') || { configs: [], data: [] }
relationForm.data.push(item) relationForm.data.push(item)
addons.setValue('relationForm', { ...relationForm }) addons.setValue('relationForm', { ...relationForm })
setTimeout(() => {
onChange(value && value.includes(' ') ? `${array.length}` : `${array.length} `)
}, 0)
} }
const addRows = () => { const addRows = () => {
...@@ -395,6 +401,9 @@ const RelationForm = (props) => { ...@@ -395,6 +401,9 @@ const RelationForm = (props) => {
let relationForm = addons.getValue('relationForm') || { configs: [], data: [] } let relationForm = addons.getValue('relationForm') || { configs: [], data: [] }
let listArray = relationForm.data.concat(items) let listArray = relationForm.data.concat(items)
addons.setValue('relationForm', { ...relationForm, data: listArray }) addons.setValue('relationForm', { ...relationForm, data: listArray })
setTimeout(() => {
onChange(value && value.includes(' ') ? `${array.length}` : `${array.length} `)
}, 0)
setVisibleOther(false) setVisibleOther(false)
} }
......
...@@ -60,7 +60,6 @@ const DateTime = (props) => { ...@@ -60,7 +60,6 @@ const DateTime = (props) => {
{...timeOtions} {...timeOtions}
style={{ width: '100%' }} style={{ width: '100%' }}
locale={locale} locale={locale}
// getPopupContainer={(targterNode) => targterNode.parentElement || document.body}
/> />
); );
......
import React, { useEffect, useState } from 'react' import React, { useEffect, useState } from 'react'
import styles from './index.less' import styles from './index.less'
import { Upload, Button, message, Modal } from 'antd' import { Upload, Button, message } from 'antd'
import { UploadOutlined, FileOutlined, ArrowDownOutlined } from '@ant-design/icons' import { UploadOutlined, FileOutlined } from '@ant-design/icons'
import FileViewer from 'react-file-viewer' import FileViewer from 'react-file-viewer'
import { uploadFileUrl, downloadFileUrl, downloadFile } from '../../../../apis/process' import { uploadFileUrl, downloadFileUrl } from '../../../../apis/process'
import { filenameVerification } from '../../../../utils' import { filenameVerification } from '../../../../utils'
import Drag from '../../../components/Drag' import Drag from '../../../components/Drag'
......
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