Commit f91ade84 authored by 彭俊龙's avatar 彭俊龙

电子手签画布范围调整,关联选择新增表数据联动

parent f22149be
{ {
"name": "panda-xform", "name": "panda-xform",
"version": "6.10.64", "version": "6.10.65",
"description": "6.10.64 电子手签加入非空校验", "description": "6.10.65 电子手签画布范围调整,关联选择新增表数据联动",
"keywords": [ "keywords": [
"panda-xform" "panda-xform"
], ],
......
...@@ -859,3 +859,11 @@ export function GetTableFieldsByTableName(params) { ...@@ -859,3 +859,11 @@ export function GetTableFieldsByTableName(params) {
params params
}) })
} }
export function GetFieldValueByTableName({params, data}) {
return request(`${BASE}/AccountManage/GetFieldValueByTableName` , {
method: "POST",
params,
data
})
}
...@@ -4253,11 +4253,24 @@ const advancedWidgets = [ ...@@ -4253,11 +4253,24 @@ const advancedWidgets = [
hidden: "{{formData.isHidden}}", hidden: "{{formData.isHidden}}",
dependencies: ['isHidden'], dependencies: ['isHidden'],
}, },
sourceType: {
title: '来源方式',
type: 'string',
widget: 'select',
default: '数据字典',
props: {
options: [
{ label: '数据字典', value: '数据字典' },
{ label: '表数据', value: '表数据' }
]
}
},
fieldParent: { fieldParent: {
title: '父字段名', title: '父字段名',
type: 'string', type: 'string',
// required: true, // required: true,
widget: 'FieldNames', widget: 'FieldNames',
hidden: "{{formData.sourceType != '数据字典'}}",
dependencies: ['$id'], dependencies: ['$id'],
}, },
dictionary: { dictionary: {
...@@ -4265,8 +4278,60 @@ const advancedWidgets = [ ...@@ -4265,8 +4278,60 @@ const advancedWidgets = [
name: '数据字典', name: '数据字典',
// required: true, // required: true,
type: 'string', type: 'string',
hidden: "{{formData.sourceType != '数据字典'}}",
widget: 'Dictionary', widget: 'Dictionary',
}, },
fieldTableKey:{
title: '联动父级字段',
type: 'string',
description: '跟随父级字段值变化加载数据',
hidden: "{{formData.sourceType != '表数据'}}",
widget: 'FollowFieldHide',
},
whereType: {
title: '联动条件',
type: 'string',
widget: 'select',
props: {
options: [
{ label: '等于', value: '等于' },
{ label: '包含', value: '包含' }
]
},
hidden: "{{formData.sourceType != '表数据'}}",
},
tableName: {
title: '表名',
name: '表名',
hidden: '{{formData.sourceType !== "表数据"}}',
type: 'string',
widget: 'TableName',
dependencies: ['sourceType'],
},
whereField: {
title: '联动字段名',
name: '联动字段名',
hidden: '{{formData.sourceType !== "表数据"}}',
type: 'string',
widget: 'FieldName',
dependencies: ['tableName'],
},
displayName: {
title: '展示字段名',
name: '展示字段名',
hidden: '{{formData.sourceType !== "表数据"}}',
type: 'string',
widget: 'FieldName',
dependencies: ['tableName'],
},
fieldName: {
title: '存储字段名',
name: '存储字段名',
hidden: '{{formData.sourceType !== "表数据"}}',
type: 'string',
widget: 'FieldName',
dependencies: ['tableName'],
},
required: { required: {
title: '必填', title: '必填',
type: 'boolean', type: 'boolean',
......
...@@ -15,6 +15,7 @@ const Signature = (props) => { ...@@ -15,6 +15,7 @@ const Signature = (props) => {
const [checked, setChecked] = useState(false) const [checked, setChecked] = useState(false)
const [signature, setSignature] = useState('') const [signature, setSignature] = useState('')
const canvasRef = useRef(null) const canvasRef = useRef(null)
let divRef = useRef(null)
const open = () => { const open = () => {
if (addons) { if (addons) {
getSignature() getSignature()
...@@ -80,6 +81,9 @@ const Signature = (props) => { ...@@ -80,6 +81,9 @@ const Signature = (props) => {
} }
useEffect(()=>{ useEffect(()=>{
if(divRef.current){
console.log(divRef.current, 'divRef.currentdivRef.currentdivRef.currentdivRef.current')
}
if (canvasRef.current && showDate) { if (canvasRef.current && showDate) {
const canvas = canvasRef.current.getCanvas(); // 获取底层的Canvas元素 const canvas = canvasRef.current.getCanvas(); // 获取底层的Canvas元素
const ctx = canvas.getContext('2d'); const ctx = canvas.getContext('2d');
...@@ -135,10 +139,10 @@ const Signature = (props) => { ...@@ -135,10 +139,10 @@ const Signature = (props) => {
disabled ? ( disabled ? (
<img src={`${window.origin}/PandaWorkFlow/WorkFlow/AccountManage/DownloadFiles?filePath=${value}`}></img> <img src={`${window.origin}/PandaWorkFlow/WorkFlow/AccountManage/DownloadFiles?filePath=${value}`}></img>
) : ( ) : (
<div style={{ background: '#F1F1F1', borderRadius: '5px' }}> <div ref={divRef} style={{ background: '#F1F1F1', borderRadius: '5px', width: '100%', height: '100%', minHeight: '300px' }}>
<ReactSignatureCanvas <ReactSignatureCanvas
ref={canvasRef} ref={canvasRef}
canvasProps={{ width: 500, height: 300 }} canvasProps={{ width: divRef.current?.offsetWidth, height: divRef.current?.offsetHeight }}
/> />
</div> </div>
) )
......
import React, { useEffect, useState } from 'react' import React, { useEffect, useState, useMemo } from 'react'
import { Select, message } from 'antd' import { Select, message } from 'antd'
import { GetSelectItemList } from '../../../../apis/process' import { GetSelectItemList, GetFieldValueFromTable, GetFieldValueByTableName } from '../../../../apis/process'
import eventEmitter from '../../../../utils/eventEmitter';
const { Option } = Select const { Option } = Select
const RelevanceSelect = (props) => { const RelevanceSelect = (props) => {
const { value, onChange, schema, addons } = props const { value, onChange, schema, addons, title } = props
const { disabled, placeholder, fieldParent, dictionary, presetValue } = schema const { $id, disabled, placeholder, fieldParent, dictionary, presetValue, whereField, whereType, sourceType, fieldTableKey, tableName, fieldName, displayName } = schema
const [options, setOptions] = useState([]) const [options, setOptions] = useState([])
const [tableData, setTableData] = useState([])
//用于表数据的父子级控件之间联动
useEffect(() => {
if(getTargetPath()){
const path = getTargetPath()
eventEmitter.on(`${path}_event`, (val)=> dealParentData(val))
}
return () => {
if(getTargetPath()){
const path = getTargetPath(fieldTableKey)
eventEmitter.removeAllListeners(`${path}_event`);
}
}
}, [addons])
useEffect(() => { useEffect(() => {
if (addons) { if (addons) {
addons.setValue(addons.dataPath, presetValue || '') addons.setValue(addons.dataPath, presetValue || '')
if(!fieldTableKey && getChildrenSchemaByKey(title)){//表数据类型的父级控件联动子级加载数据
eventEmitter.emit(`${addons?.dataPath}_event`, presetValue || '')
}
} else { } else {
onChange(presetValue) onChange(presetValue)
} }
}, [presetValue]) if(sourceType === '表数据'){
getTableData()
}
}, [presetValue, sourceType])
const selectChange = (value) => { const selectChange = (value) => {
if (addons) { if (addons) {
onChange(value || '') onChange(value || '')
if(getChildrenSchemaByKey(title)){
eventEmitter.emit(`${addons?.dataPath}_event`, value)
}
}
}
///处理父级传入的数据-表数据
const dealParentData = async (val) => {
console.log(val, '父级数据');
const { code, data, msg } = await GetFieldValueByTableName({
params: {
tableName: tableName,
fieldName: `${displayName},${fieldName}`,
},
data: [{
field: whereField,
type: whereType,
value: val
}]
})
if (code === 0) {
if (Array.isArray(data)) {
setTableData(data.filter(v => v))
} else {
setTableData([])
}
} else {
message.error(msg)
}
}
const getTargetPath = () => {
if(sourceType != '表数据' || !fieldTableKey || !addons) return null;
let targetPath = null
for(const k of Object.keys(addons.formData)){
for(const s of Object.keys(addons.formData[k])){
if(fieldTableKey === s){
targetPath = `${k}.${s}`
break;
}
}
}
return targetPath
}
const getChildrenSchemaByKey = (key) => {
if(sourceType != '表数据') return null;
let schema = null;
for(const k of Object.keys(addons.formData)){
for(const s of Object.keys(addons.formData[k])){
const path = `${k}.${s}`
let _schema = addons?.getSchemaByPath(path)
if(_schema?.fieldTableKey === key){
schema = _schema
break;
}
}
} }
return schema
} }
const enums = useMemo(() => {
switch (sourceType) {
case '数据字典':
return Array.isArray(options) ? options : []
case '表数据':
return Array.isArray(tableData) ? tableData : []
default:
return []
}
}, [sourceType, options, tableData])
const children = useMemo(() => {
let children = []
if (Array.isArray(enums)) {
enums.forEach(v => {
if (sourceType === '数据字典') {
children.push(<Option value={v.nodeValue} key={i}>{v.nodeValue}</Option>)
} else {
let displayData = v?.find(v=> v.fieldName === displayName)
let fieldNameData = v?.find(v=> v.fieldName === fieldName)
children.push(<Option key={v} value={fieldNameData?.fieldValue}>{displayData?.fieldValue}</Option>)
}
})
}
return children
}, [sourceType, enums])
const onfocus = async () => { const onfocus = async () => {
if (!addons) return if (!addons) return
if(sourceType === '数据字典') {
getDictionary()
}else if(!fieldTableKey){
getTableData()
}
}
const getTableData = async () => {
if (!tableName) {
return message.info('请选择表名!')
}
if (!fieldName) {
return message.info('请选择存储字段名!')
}
if (!displayName) {
return message.info('请选择展示字段名!')
}
const { code, data, msg } = await GetFieldValueByTableName({
params: {
tableName: tableName,
fieldName: `${displayName},${fieldName}`,
},
data: []
})
if (code === 0) {
if (Array.isArray(data)) {
setTableData(data.filter(v => v))
} else {
setTableData([])
}
} else {
message.error(msg)
}
}
const getDictionary = async () => {
if (!dictionary) { if (!dictionary) {
return message.error('缺少数据字典!') return message.error('缺少数据字典!')
} }
...@@ -51,7 +197,7 @@ const RelevanceSelect = (props) => { ...@@ -51,7 +197,7 @@ const RelevanceSelect = (props) => {
} else { } else {
message.error(msg) message.error(msg)
} }
} }
return ( return (
<Select <Select
...@@ -64,7 +210,7 @@ const RelevanceSelect = (props) => { ...@@ -64,7 +210,7 @@ const RelevanceSelect = (props) => {
allowClear allowClear
> >
{ {
options.map((v, i) => <Option value={v.nodeValue} key={i}>{v.nodeValue}</Option>) children
} }
</Select> </Select>
) )
......
...@@ -185,7 +185,7 @@ export const getVerify = (json) => { ...@@ -185,7 +185,7 @@ export const getVerify = (json) => {
let child = properties[v]?.properties let child = properties[v]?.properties
if (isObject(child)) { if (isObject(child)) {
for (let s in child) { for (let s in child) {
const { widget, sourceType, options, dictionary, tableName, fieldName, fieldParent, accountName, fieldshine } = child[s] const { widget, sourceType, options, dictionary, tableName, fieldName, fieldParent, accountName, fieldshine, } = child[s]
if (['ComboBox', 'RadioButton', 'CheckBox'].includes(widget)) { if (['ComboBox', 'RadioButton', 'CheckBox'].includes(widget)) {
if (sourceType === '手动输入' && !options.length) { if (sourceType === '手动输入' && !options.length) {
return message.error(`字段【${s}】配置,选项值必填!`) return message.error(`字段【${s}】配置,选项值必填!`)
...@@ -203,9 +203,29 @@ export const getVerify = (json) => { ...@@ -203,9 +203,29 @@ export const getVerify = (json) => {
} }
} }
if (['RelevanceSelect'].includes(widget)) { if (['RelevanceSelect'].includes(widget)) {
if (!fieldParent || !dictionary) {
if ( sourceType === '数据字典' && (!fieldParent || !dictionary)) {
return message.error(`字段【${s}】配置,父字段名与数据字典必填!`) return message.error(`字段【${s}】配置,父字段名与数据字典必填!`)
} }
if (sourceType === '表数据' ) {
const { displayName, fieldTableKey, whereType, whereField } = child[s]
if (!tableName) {
return message.error(`字段【${s}】配置,表名必填!`)
}
if (!fieldName) {
return message.error(`字段【${s}】配置,存储字段名必填!`)
}
if (!displayName) {
return message.error(`字段【${s}】配置,展示字段名必填!`)
}
if(fieldTableKey && !whereType){
return message.error(`字段【${s}】配置,联动条件必填!`)
}
if(fieldTableKey && !whereField){
return message.error(`字段【${s}】配置,联动字段名必填!`)
}
}
} }
if (['AccountSelector'].includes(widget)) { if (['AccountSelector'].includes(widget)) {
if (!accountName || !fieldshine) { if (!accountName || !fieldshine) {
......
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