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

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

parent 36dd90bc
{ {
"name": "panda-xform", "name": "panda-xform",
"version": "6.10.20", "version": "6.10.21",
"description": "6.10.20 带颜色选项支持颜色选择", "description": "6.10.21 台账选择器支持自动回填",
"keywords": [ "keywords": [
"panda-xform" "panda-xform"
], ],
......
...@@ -3049,7 +3049,7 @@ const businessWidgets = [ ...@@ -3049,7 +3049,7 @@ const businessWidgets = [
displayType: 'row', displayType: 'row',
labelWidth: 110, labelWidth: 110,
widget: 'BooleanSwitch', widget: 'BooleanSwitch',
description: '开启后会将台账中的值自动映射在表单中(移动端)', description: '开启后会将台账中的值自动映射在表单中',
}, },
isMultiple: { isMultiple: {
title: '多选', title: '多选',
......
...@@ -40,6 +40,7 @@ const AccountSelector = (props) => { ...@@ -40,6 +40,7 @@ const AccountSelector = (props) => {
placeholder, placeholder,
fieldList, fieldList,
isStoreID, isStoreID,
autofill,
} = schema } = schema
const initParams = { const initParams = {
user: userID, user: userID,
...@@ -256,12 +257,54 @@ const AccountSelector = (props) => { ...@@ -256,12 +257,54 @@ const AccountSelector = (props) => {
getDataSource({ pageIndex, pageSize }) 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(() => { useEffect(() => {
if (addons) { if (addons) {
addons.setValue(addons.dataPath, presetValue) addons.setValue(addons.dataPath, presetValue)
if (presetValue && isStoreID) { if (presetValue && isStoreID) {
getShowValue(presetValue?.split(',')) getShowValue(presetValue?.split(','))
} }
if (autofill && presetValue && fieldshine?.length) {
getAutofill()
}
} else { } else {
onChange(presetValue) 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