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

fix: 台账选择器支持存储ID

parent 94376944
{ {
"name": "panda-xform", "name": "panda-xform",
"version": "6.9.17", "version": "6.9.18",
"description": "6.9.17 支持多区域绘制", "description": "6.9.18 台账选择器支持存储ID",
"keywords": [ "keywords": [
"panda-xform" "panda-xform"
], ],
......
...@@ -328,7 +328,7 @@ export function GetTableDataInfo({ accountName, id, timeLimit }) { ...@@ -328,7 +328,7 @@ export function GetTableDataInfo({ accountName, id, timeLimit }) {
// headers: { // headers: {
// 'Civ-Site': window?.globalConfig?.userInfo?.site // 'Civ-Site': window?.globalConfig?.userInfo?.site
// }, // },
url: `${BASEURL}/GetTableDataInfo?accountName=${accountName}&id=${id}&timeLimit=${timeLimit}`, url: `${BASEURL}/GetTableDataInfo?accountName=${accountName}&id=${id}${timeLimit ? `&timeLimit=${timeLimit}` : ''}`,
method: 'GET', method: 'GET',
}); });
} }
......
...@@ -1682,25 +1682,35 @@ const businessWidgets = [ ...@@ -1682,25 +1682,35 @@ const businessWidgets = [
dependencies: ['accountName', '$id'], dependencies: ['accountName', '$id'],
description: '默认获取前端台账字段', description: '默认获取前端台账字段',
}, },
isStoreID: {
title: '存储ID',
name: '存储ID',
type: 'boolean',
default: false,
displayType: 'row',
labelWidth: 110,
widget: 'BooleanSwitch',
description: '开启后将会存储台账的ID',
},
siteFilter: { siteFilter: {
title: '站点过滤', title: '站点过滤',
name: '站点过滤', name: '站点过滤',
type: 'boolean', type: 'boolean',
default: false, default: false,
displayType: 'row', displayType: 'row',
labelWidth: 160, labelWidth: 110,
widget: 'BooleanSwitch', widget: 'BooleanSwitch',
description: '开启后只显示自己所属站点数据', description: '开启后只显示自己所属站点数据',
}, },
autofill: { autofill: {
title: '自动映射值(移动端)', title: '自动映射值',
name: '站点过滤', name: '站点过滤',
type: 'boolean', type: 'boolean',
default: false, default: false,
displayType: 'row', displayType: 'row',
labelWidth: 160, labelWidth: 110,
widget: 'BooleanSwitch', widget: 'BooleanSwitch',
description: '开启后会将台账中的值自动映射在表单中', description: '开启后会将台账中的值自动映射在表单中(移动端)',
}, },
isMultiple: { isMultiple: {
title: '多选', title: '多选',
......
import React, { useState, useEffect, useRef } from 'react' import React, { useState, useEffect, useRef, useMemo } from 'react'
import { Input, message, Pagination } from 'antd' import { Input, message, Pagination } from 'antd'
import { SnippetsOutlined } from '@ant-design/icons' import { SnippetsOutlined } from '@ant-design/icons'
import { GetAccountConfigInfo, GetAccountPageList, getStationListByUserID } from '../../../../apis/process' import { GetAccountConfigInfo, GetAccountPageList, getStationListByUserID, GetTableDataInfo } from '../../../../apis/process'
import styles from './index.less'; import styles from './index.less';
import { isJson } from '../../../../utils' import { isJson, isObject } from '../../../../utils'
import TablePack from '../../../../core/Account/components/TablePack' import TablePack from '../../../../core/Account/components/TablePack'
import SearchGroup from '../../../../core/Account/components/SearchGroup' import SearchGroup from '../../../../core/Account/components/SearchGroup'
import Drag from '../../../components/Drag' import Drag from '../../../components/Drag'
...@@ -29,7 +29,18 @@ const AccountSelector = (props) => { ...@@ -29,7 +29,18 @@ const AccountSelector = (props) => {
const userID = window?.globalConfig?.userInfo?.OID || 1 const userID = window?.globalConfig?.userInfo?.OID || 1
const codes = window?.pandaXform?.codes || { 工单编号: '', 事件编号: '', } const codes = window?.pandaXform?.codes || { 工单编号: '', 事件编号: '', }
const { value, onChange, schema, addons } = props const { value, onChange, schema, addons } = props
const { disabled, accountName, fieldshine, siteFilter, sql, isMultiple, presetValue, placeholder, fieldList } = schema const {
disabled,
accountName,
fieldshine,
siteFilter,
sql,
isMultiple,
presetValue,
placeholder,
fieldList,
isStoreID,
} = schema
const initParams = { const initParams = {
user: userID, user: userID,
accountName, accountName,
...@@ -42,6 +53,7 @@ const AccountSelector = (props) => { ...@@ -42,6 +53,7 @@ const AccountSelector = (props) => {
siteFilter, siteFilter,
...defaultParams, ...defaultParams,
} }
const [showValue, setShowValue] = useState('')
const [params, setParams] = useState(initParams) const [params, setParams] = useState(initParams)
const [loading, setLoading] = useState(false) const [loading, setLoading] = useState(false)
const [dataSource, setDataSource] = useState([]) const [dataSource, setDataSource] = useState([])
...@@ -160,12 +172,36 @@ const AccountSelector = (props) => { ...@@ -160,12 +172,36 @@ const AccountSelector = (props) => {
return value return value
} }
const getShowValue = (keys) => {
let array = []
if (keys.length) {
keys.forEach(v => {
array.push(GetTableDataInfo({ accountName: accountName, id: v, timeLimit: null }))
})
Promise.all(array).then(res => {
let showArray = []
res?.forEach(v => {
if (v.code === 0) {
v.data?.forEach(v => {
if (v.fieldName === fieldshine[0].fromField) {
showArray.push(v.fieldValue)
}
})
}
})
setShowValue(showArray.join(','))
})
}
}
const onOk = () => { const onOk = () => {
if (fieldshine.length > 1) { if (fieldshine.length > 1) {
let row = dataSource.find(v => v.ID === keys[0]) || {}; let row = dataSource.find(v => v.ID === keys[0]) || {};
Object.keys(addons.formData).forEach(child => { Object.keys(addons.formData).forEach(child => {
Object.keys(addons.formData[child]).forEach(sun => { let childObj = addons.formData[child]
fieldshine.forEach(v => { if (isObject(childObj)) {
Object.keys(childObj).forEach(sun => {
fieldshine.forEach((v, index) => {
if (sun === v.toField) { if (sun === v.toField) {
const schema = addons.getSchemaByPath(`${child}.${sun}`); const schema = addons.getSchemaByPath(`${child}.${sun}`);
if (['TextInput', 'fileUpload'].includes(schema.widget)) { if (['TextInput', 'fileUpload'].includes(schema.widget)) {
...@@ -176,17 +212,28 @@ const AccountSelector = (props) => { ...@@ -176,17 +212,28 @@ const AccountSelector = (props) => {
} else { } else {
addons.setValue(`${child}.${sun}`, row[v.fromField] || ''); addons.setValue(`${child}.${sun}`, row[v.fromField] || '');
} }
//存储ID特殊处理
if (isStoreID && index === 0) {
addons.setValue(`${child}.${sun}`, keys[0] || '')
getShowValue(keys)
}
} }
}); });
}); });
}
}); });
} else { } else {
let array = dataSource.filter(v => keys.includes(v.ID)); let array = dataSource.filter(v => keys.includes(v.ID));
if (array.length) { if (array.length) {
if (isStoreID) {
onChange(`${keys.join(',')}` || '')
getShowValue(keys)
} else {
let rowValues = array.map(v => v[fieldshine[0].fromField]).filter(v => v).join(','); let rowValues = array.map(v => v[fieldshine[0].fromField]).filter(v => v).join(',');
onChange(rowValues); onChange(rowValues);
} }
} }
}
setVisible(false); setVisible(false);
} }
...@@ -210,6 +257,9 @@ const AccountSelector = (props) => { ...@@ -210,6 +257,9 @@ const AccountSelector = (props) => {
useEffect(() => { useEffect(() => {
if (addons) { if (addons) {
addons.setValue(addons.dataPath, presetValue) addons.setValue(addons.dataPath, presetValue)
if (presetValue && isStoreID) {
getShowValue(presetValue?.split(','))
}
} else { } else {
onChange(presetValue) onChange(presetValue)
} }
...@@ -221,12 +271,17 @@ const AccountSelector = (props) => { ...@@ -221,12 +271,17 @@ const AccountSelector = (props) => {
<div className={styles.AccountSelector}> <div className={styles.AccountSelector}>
<Input <Input
placeholder={disabled ? (placeholder || '') : (placeholder || '点击选择台账')} placeholder={disabled ? (placeholder || '') : (placeholder || '点击选择台账')}
value={value} value={isStoreID ? showValue : value}
// value={value}
onClick={() => iconClick()} onClick={() => iconClick()}
addonAfter={!disabled ? addonAfter : null} addonAfter={!disabled ? addonAfter : null}
disabled={disabled} disabled={disabled}
allowClear allowClear
onChange={e => onChange('')} className=''
onChange={e => {
onChange('')
setShowValue('')
}}
/> />
<Drag <Drag
onCancel={() => setVisible(false)} onCancel={() => setVisible(false)}
......
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