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

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

parent adbbac63
{
"name": "panda-xform",
"version": "6.10.95",
"description": "6.10.95 日期时间控件分钟选择间隔从5改为1",
"version": "6.10.98",
"description": "6.10.98 支持行内时间自动计算、前端生成编码",
"keywords": [
"panda-xform"
],
......
......@@ -56,7 +56,8 @@ const ValueEdit = (props) => {
tableName,
whereField,
whereType,
_fieldName
_fieldName,
role
} = props
const property = isStoreID ? 'userID' : 'userName'
useEffect(() => {
......@@ -205,7 +206,7 @@ const ValueEdit = (props) => {
const getUsers = async () => {
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 (data) {
setPullDown(data.dropdownList.map((v, i) => {
......@@ -275,11 +276,36 @@ const ValueEdit = (props) => {
style={{ width: '100%' }}
locale={locale}
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) {
onChange({ fieldName, fieldValue: moment(date._d).format('YYYY-MM-DD HH:mm:ss') })
} else {
onChange({ fieldName, fieldValue: '' })
}
}
}}
/>
)
......@@ -294,13 +320,13 @@ const ValueEdit = (props) => {
value={value === '' ? null : Number(value)}
onChange={(value) => {
if (autoArray.length) {
console.log(autoArray,'autoArray')
let filedFormulas = autoArray.flatMap(x => x.filedFormulas || []);
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 !== null ? `${value}` : '' }
}
return { fieldName: s, fieldValue: record?.[s] || '' }
......
......@@ -153,8 +153,6 @@ const formAutomatic = async (params) => {
}
})
}
} else {
message.error(msg)
}
}
......
......@@ -10,7 +10,7 @@ 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)
}
......@@ -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 = (
<div>
<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