Commit 3ebbdc7f authored by 田翔's avatar 田翔

fix: 台账选择器支持自动回填

parent 36dd90bc
{
"name": "panda-xform",
"version": "6.10.20",
"description": "6.10.20 带颜色选项支持颜色选择",
"version": "6.10.21",
"description": "6.10.21 台账选择器支持自动回填",
"keywords": [
"panda-xform"
],
......
......@@ -3049,7 +3049,7 @@ const businessWidgets = [
displayType: 'row',
labelWidth: 110,
widget: 'BooleanSwitch',
description: '开启后会将台账中的值自动映射在表单中(移动端)',
description: '开启后会将台账中的值自动映射在表单中',
},
isMultiple: {
title: '多选',
......
......@@ -40,6 +40,7 @@ const AccountSelector = (props) => {
placeholder,
fieldList,
isStoreID,
autofill,
} = schema
const initParams = {
user: userID,
......@@ -256,12 +257,54 @@ const AccountSelector = (props) => {
getDataSource({ pageIndex, pageSize })
}
const getAutofill = async () => {
if (fieldshine?.[0]?.toField) {
let param = {
...params,
user: userID,
accountName: accountName,
condition: sql ? window.btoa(encodeURIComponent(sql)) : '',
queryWheres: [{ field: fieldshine?.[0]?.toField, type: '等于', value: presetValue }]
}
const { data, code, msg } = await GetAccountPageList(param)
if (code === 0) {
let list = data.jsonData ? JSON.parse(data.jsonData) : []
if (list.length) {
let row = list[0]
let formData = addons.formData
Object.keys(formData).forEach(child => {
Object.keys(formData[child]).forEach(sun => {
fieldshine.forEach((v, index) => {
if (sun === v.toField) {
const schema = addons.getSchemaByPath(`${child}.${sun}`)
if (['FileUpload', 'TextInput'].includes(schema.widget)) {
addons.setSchemaByPath(`${child}.${sun}`, { ...schema, otherValue: row[v.fromField] })
} else {
addons.setValue(`${child}.${sun}`, row[v.fromField] || '')
}
}
//存储ID特殊处理
// if (isStoreID && index === 0) {
// addons.setValue(`${child}.${sun}`, row[v.fromField] || '')
// getShowValue([row[v.fromField]])
// }
})
})
})
}
}
}
}
useEffect(() => {
if (addons) {
addons.setValue(addons.dataPath, presetValue)
if (presetValue && isStoreID) {
getShowValue(presetValue?.split(','))
}
if (autofill && presetValue && fieldshine?.length) {
getAutofill()
}
} else {
onChange(presetValue)
}
......
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