Commit 5adb9df4 authored by 彭俊龙's avatar 彭俊龙

feat: 支持行内时间自动计算、前端生成编码

parent adbbac63
{ {
"name": "panda-xform", "name": "panda-xform",
"version": "6.10.95", "version": "6.10.98",
"description": "6.10.95 日期时间控件分钟选择间隔从5改为1", "description": "6.10.98 支持行内时间自动计算、前端生成编码",
"keywords": [ "keywords": [
"panda-xform" "panda-xform"
], ],
......
...@@ -56,7 +56,8 @@ const ValueEdit = (props) => { ...@@ -56,7 +56,8 @@ const ValueEdit = (props) => {
tableName, tableName,
whereField, whereField,
whereType, whereType,
_fieldName _fieldName,
role
} = props } = props
const property = isStoreID ? 'userID' : 'userName' const property = isStoreID ? 'userID' : 'userName'
useEffect(() => { useEffect(() => {
...@@ -205,7 +206,7 @@ const ValueEdit = (props) => { ...@@ -205,7 +206,7 @@ const ValueEdit = (props) => {
const getUsers = async () => { const getUsers = async () => {
let time = new Date().getTime() + Math.random() let time = new Date().getTime() + Math.random()
const { code, data, msg } = await getUserSelector('', false ,time) const { code, data, msg } = await getUserSelector(role, false ,time)
if (code === 0) { if (code === 0) {
if (data) { if (data) {
setPullDown(data.dropdownList.map((v, i) => { setPullDown(data.dropdownList.map((v, i) => {
...@@ -275,11 +276,36 @@ const ValueEdit = (props) => { ...@@ -275,11 +276,36 @@ const ValueEdit = (props) => {
style={{ width: '100%' }} style={{ width: '100%' }}
locale={locale} locale={locale}
onChange={(date) => { onChange={(date) => {
console.log(autoArray, props, date, '时间选择计算');
if (autoArray.length) {
let value = (date && date.format('YYYY-MM-DD HH:mm:ss')) || ''
let filedFormulas = [] ;//autoArray.flatMap(x => x.filedFormulas || []);
let vals = []
autoArray.forEach(v => {
if (v.fields.includes(fieldName)) {
let values = v.fields.map(s => {
if (s === fieldName) {
filedFormulas = v.filedFormulas.map(x => x)
return { fieldName, fieldValue: value }
}
return { fieldName: s, fieldValue: record?.[s] || '' }
})
vals= [...vals, ...values]
}
})
let params = {
filedFormulas,
tableName: autoArray[0].tableName,
values: vals
}
formAuto(params, otherChange)
}else{
if (date && date._d) { if (date && date._d) {
onChange({ fieldName, fieldValue: moment(date._d).format('YYYY-MM-DD HH:mm:ss') }) onChange({ fieldName, fieldValue: moment(date._d).format('YYYY-MM-DD HH:mm:ss') })
} else { } else {
onChange({ fieldName, fieldValue: '' }) onChange({ fieldName, fieldValue: '' })
} }
}
}} }}
/> />
) )
...@@ -294,13 +320,13 @@ const ValueEdit = (props) => { ...@@ -294,13 +320,13 @@ const ValueEdit = (props) => {
value={value === '' ? null : Number(value)} value={value === '' ? null : Number(value)}
onChange={(value) => { onChange={(value) => {
if (autoArray.length) { if (autoArray.length) {
console.log(autoArray,'autoArray') let filedFormulas = [];//autoArray.flatMap(x => x.filedFormulas || []);
let filedFormulas = autoArray.flatMap(x => x.filedFormulas || []);
let vals = [] let vals = []
autoArray.forEach(v => { autoArray.forEach(v => {
if (v.fields.includes(fieldName)) { if (v.fields.includes(fieldName)) {
let values = v.fields.map(s => { let values = v.fields.map(s => {
if (s === fieldName) { if (s === fieldName) {
filedFormulas = v.filedFormulas.map(x => x)
return { fieldName, fieldValue: value !== null ? `${value}` : '' } return { fieldName, fieldValue: value !== null ? `${value}` : '' }
} }
return { fieldName: s, fieldValue: record?.[s] || '' } return { fieldName: s, fieldValue: record?.[s] || '' }
......
...@@ -153,8 +153,6 @@ const formAutomatic = async (params) => { ...@@ -153,8 +153,6 @@ const formAutomatic = async (params) => {
} }
}) })
} }
} else {
message.error(msg)
} }
} }
......
...@@ -10,7 +10,7 @@ const Coding = (props) => { ...@@ -10,7 +10,7 @@ const Coding = (props) => {
const prefixCls = getPrefixCls('pandaXform') const prefixCls = getPrefixCls('pandaXform')
const { value, onChange, addons, schema } = props const { value, onChange, addons, schema } = props
const { disabled, prefixion, codingType, presetValue, required, placeholder } = schema const { disabled, prefixion, codingType, presetValue, required, placeholder } = schema
console.log(props, 'propspropspropspropsprops');
const inputChange = (e) => { const inputChange = (e) => {
onChange(e.target.value) onChange(e.target.value)
} }
...@@ -23,6 +23,31 @@ const Coding = (props) => { ...@@ -23,6 +23,31 @@ const Coding = (props) => {
} }
}, []) }, [])
useEffect(()=>{
if(!value && !presetValue){
const val = generateCode(Number(codingType))
onChange(val)
}
}, [])
const generateCode = (type) => {
const prefix = prefixion || '';
const year = new Date().getFullYear().toString();
const month = (new Date().getMonth() + 1).toString().padStart(2, '0');
const randomSixDigits = Math.floor(100000 + Math.random() * 900000).toString();
const randomEightDigits = Math.floor(10000000 + Math.random() * 90000000).toString();
switch (type) {
case 1:
return `${prefix}-${year}-${randomSixDigits}`;
case 2:
return `${prefix}-${year}${month}-${randomSixDigits}`;
case 3:
return `${prefix}-${randomEightDigits}`;
default:
return '';
}
};
const content = ( const content = (
<div> <div>
<QRcode value={value} /> <QRcode value={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