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

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

parent 3fcf458a
{
"name": "panda-xform",
"version": "5.0.7",
"description": "5.0.7 关联表单增加可编辑状态与台账导入",
"version": "5.0.8",
"description": "5.0.8 关联表单可编辑增加数值与日期形态",
"keywords": [
"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'
import FileView from './components/FileView'
import CoordView from './components/CoordView'
import SelectView from './components/SelectView'
import ValueEdit from './components/ValueEdit'
import IconPack from '../../../components/IconPack'
import { isObject, isArray, getFieldInfo } from '../../../../utils'
......@@ -228,13 +229,17 @@ const TablePack = (props, ref) => {
},
}),
render: (value, record) => {
if (isEdit) {
let props = { ...json[fieldName], value }
if (isEdit && !notUse?.includes('edit')) {
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 {
let props = { ...json[fieldName], value }
if (widget === 'FileUpload') {
if (['FileUpload'].includes(widget)) {
return <FileView {...props} />
}
if (['Coordinate', 'Device', 'DrawPath', 'DrawArea'].includes(widget)) {
......@@ -251,17 +256,25 @@ const TablePack = (props, ref) => {
const btns = useMemo(() => {
let array = []
if (!notUse?.includes('read')) {
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 /> })
//表格可编辑
if (isEdit) {
if (!notUse?.includes('del')) {
array.push({ title: '删除', icon: <IconPack.ShanChu /> })
}
} else {
if (!notUse?.includes('read')) {
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
}, [notUse, parent])
}, [notUse, isEdit])
const checkChange = (values) => {
setChecks(values)
......@@ -335,7 +348,7 @@ const TablePack = (props, ref) => {
if (btns.length) {
columns.push(
{
title: isEdit ? '操作' : (
title: (
<div className={styles.operation}>
<span>操作</span>
<span className={styles.operationSpan}>
......@@ -362,7 +375,7 @@ const TablePack = (props, ref) => {
</span>
</div>
),
width: isEdit ? 75 : btns.length * 35 + 30,
width: btns.length * 35 + 30,
align: 'center',
filteredValue: null,
fixed: 'right',
......@@ -370,7 +383,7 @@ const TablePack = (props, ref) => {
return (
<div style={{ display: 'flex', justifyContent: 'center' }}>
{
(isEdit ? [{ title: '删除', icon: <IconPack.ShanChu /> }] : btns).map(v => {
btns.map(v => {
if (v.title === '删除') {
return (
<Popconfirm
......@@ -412,7 +425,7 @@ const TablePack = (props, ref) => {
return fileColumns
}
return columns
}, [parent, btns, dataSource, fileColumns, checks, open, isEdit])
}, [parent, btns, dataSource, fileColumns, checks, open])
const onChange = (page, filters, sorter) => {
setFilteredInfo(filters)
......@@ -434,6 +447,8 @@ const TablePack = (props, ref) => {
tableChange?.({}, filtered, sortedInfo)
}
console.log('props', props, btns, columns)
return (
<div className={styles.tablePack} style={{ paddingTop: filtered.length ? '30px' : '10px' }}>
{
......
......@@ -138,9 +138,9 @@ const RelationForm = (props) => {
}
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: [] }
if (r.ID.includes('前端ID')) {
if (r?.ID?.includes('前端ID')) {
let list = relationForm.data.filter(v => v.ID !== r.ID)
addons.setValue('relationForm', { ...relationForm, data: list })
} else {
......@@ -281,13 +281,16 @@ const RelationForm = (props) => {
let formValue = []
let field = config?.accountFieids?.filter(v => v.webDisplay).map(v => v.fieldName)
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 relationForm = addons.getValue('relationForm') || { configs: [], data: [] }
let listArray = relationForm.data.filter(v => v.ID !== itemData.ID)
listArray.push(itemData)
addons.setValue('relationForm', { ...relationForm, data: listArray })
setTimeout(() => {
onChange(value && value.includes(' ') ? `${array.length}` : `${array.length} `)
}, 0)
} else {
rowClick(type, row)
}
......@@ -323,6 +326,9 @@ const RelationForm = (props) => {
let relationForm = addons.getValue('relationForm') || { configs: [], data: [] }
relationForm.data.push(item)
addons.setValue('relationForm', { ...relationForm })
setTimeout(() => {
onChange(value && value.includes(' ') ? `${array.length}` : `${array.length} `)
}, 0)
}
const addRows = () => {
......@@ -395,6 +401,9 @@ const RelationForm = (props) => {
let relationForm = addons.getValue('relationForm') || { configs: [], data: [] }
let listArray = relationForm.data.concat(items)
addons.setValue('relationForm', { ...relationForm, data: listArray })
setTimeout(() => {
onChange(value && value.includes(' ') ? `${array.length}` : `${array.length} `)
}, 0)
setVisibleOther(false)
}
......
......@@ -60,7 +60,6 @@ const DateTime = (props) => {
{...timeOtions}
style={{ width: '100%' }}
locale={locale}
// getPopupContainer={(targterNode) => targterNode.parentElement || document.body}
/>
);
......
import React, { useEffect, useState } from 'react'
import styles from './index.less'
import { Upload, Button, message, Modal } from 'antd'
import { UploadOutlined, FileOutlined, ArrowDownOutlined } from '@ant-design/icons'
import { Upload, Button, message } from 'antd'
import { UploadOutlined, FileOutlined } from '@ant-design/icons'
import FileViewer from 'react-file-viewer'
import { uploadFileUrl, downloadFileUrl, downloadFile } from '../../../../apis/process'
import { uploadFileUrl, downloadFileUrl } from '../../../../apis/process'
import { filenameVerification } from '../../../../utils'
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