Commit cbedc92e authored by 田翔's avatar 田翔

fix: 台账选择器完成,统一增加说明属性替代强调

parent 4489aaf3
{
"name": "panda-xform",
"version": "1.5.1",
"description": "1.5.1: 增加唯一值校验,增加位置坐标,增加业务选择",
"version": "1.5.2",
"description": "1.5.2: 台账选择器完成,统一增加说明属性替代强调",
"keywords": [
"panda-xform"
],
......@@ -126,4 +126,4 @@
"publishConfig": {
"registry": "https://g.civnet.cn:4873"
}
}
}
\ No newline at end of file
This diff is collapsed.
import React, { useRef, useEffect, useState, useContext } from 'react'
import React, { useRef, useEffect, useState, useContext, forwardRef, createContext, useMemo } from 'react'
import { ConfigProvider, message, Modal } from 'antd'
import Generator, { defaultCommonSettings, defaultGlobalSettings, defaultSettings } from 'fr-generator'
import Generator from 'fr-generator'
import { settings, baseSettings, globalSettings } from './config'
import widgets from '../widgets'
import { saveTableConfig, GetTableConfigJson } from '../../apis/process'
import FormRender from '../FormRender'
const FormDesigner = (props) => {
export const GlobalStore = createContext(null)
const FormDesigner = (props, ref) => {
const { tableName } = props
......@@ -14,7 +16,18 @@ const FormDesigner = (props) => {
const prefixCls = getPrefixCls('pandaXform')
const [visible, setVisible] = useState(false)
const [schema, setSchema] = useState({})
const ref = useRef(null)
const designerRef = useRef(null)
const settingsParent = useMemo(() => {
let settingsParent = []
settings.forEach(v => {
v.widgets.forEach(s => {
s.schema = { ...s.schema, tableNameParent: tableName }
})
settingsParent.push(v)
})
return settingsParent
}, [settings, tableName])
const getTableField = () => {
console.log('setSchema', settings)
......@@ -25,7 +38,7 @@ const FormDesigner = (props) => {
if (code === 0) {
if (typeof data === 'string') {
setTimeout(() => {
ref && ref.current && ref.current.setValue && ref.current.setValue(JSON.parse(data))
designerRef && designerRef.current && designerRef.current.setValue && designerRef.current.setValue(JSON.parse(data))
setSchema(JSON.parse(data))
}, 0)
}
......@@ -47,17 +60,17 @@ const FormDesigner = (props) => {
text: '预览',
onClick: (e) => {
setVisible(true)
setSchema(ref.current.getValue())
setSchema(designerRef.current.getValue())
}
},
{
text: '提交',
onClick: async (value) => {
const errors = ref.current.getErrorFields()
const errors = designerRef.current.getErrorFields()
if (errors.length) {
return message.error('请按照提示完善表单内容')
}
const { code, data, msg } = await saveTableConfig(ref.current.getValue())
const { code, data, msg } = await saveTableConfig(designerRef.current.getValue())
if (code === 0) {
message.info('保存成功')
} else {
......@@ -84,12 +97,12 @@ const FormDesigner = (props) => {
object: 'Header',
}}
validation={true}
ref={ref}
ref={designerRef}
extraButtons={extraButtons}
onChange={onChange}
widgets={widgets}
onCanvasSelect={onCanvasSelect}
settings={settings}
settings={settingsParent}
commonSettings={baseSettings}
globalSettings={globalSettings}
/>
......@@ -100,7 +113,6 @@ const FormDesigner = (props) => {
onOk={() => setVisible(false)}
onCancel={() => setVisible(false)}
visible={visible}
// getContainer={false}
destroyOnClose
>
<FormRender schema={schema} />
......@@ -111,4 +123,4 @@ const FormDesigner = (props) => {
}
export default FormDesigner
\ No newline at end of file
export default forwardRef(FormDesigner)
\ No newline at end of file
const schema = {
"type": "object",
"properties": {
"formGroup_1": {
"type": "object",
"title": "文本类",
"properties": {
"多行文本": {
"title": "多行文本",
"type": "string",
"format": "textarea",
"default": "",
"min": 0,
"max": 254,
"className": "",
"showDescIcon": true,
"column": 1,
"required": false,
"widget": "textArea",
"rules": [
{
"patterns": false,
"message": ""
}
],
"disabled": false,
"placeholder": "请输入多行文本",
"width": "100%",
"pathKey": "formGroup_1"
},
"富文本": {
"title": "富文本",
"widget": "RichText",
"type": "string",
"config": "",
"format": "text",
"className": "",
"default": "富文本默认值",
"content": "富文本默认值",
"min": 0,
"max": 254,
"disabled": false,
"showDescIcon": true,
"required": false,
"widget": "RichText",
"rules": [
{},
{
"pattern": false,
"message": ""
}
],
"width": "100%",
"pathKey": "formGroup_1"
},
},
"required": [],
"className": "ant-pandaXform-group"
},
},
"required": [],
"column": 4,
"displayType": "row",
"showDescIcon": true,
"labelWidth": 120
}
export default schema
\ No newline at end of file
import React, { useState, useContext, forwardRef } from 'react'
import React, { useState, useContext, forwardRef, createContext } from 'react'
import FormRender, { useForm } from 'form-render'
import { ConfigProvider } from 'antd'
import widgets from '../widgets'
......
......@@ -4,8 +4,6 @@ import moment from 'moment'
const Time = (props) => {
console.log('props', props)
const { value, onChange, schema, addons } = props
const { presetValue, currentDate, defaultCurrent } = schema
......
import React, { useEffect, useMemo, useState } from 'react'
import React, { useEffect, useState } from 'react'
import styles from './index.less'
import { Upload, Button, message, Modal } from 'antd'
import { UploadOutlined, FileOutlined, ArrowDownOutlined } from '@ant-design/icons'
......
......@@ -9,7 +9,7 @@ const AccountSelector = (props) => {
const userID = window?.globalConfig?.userInfo?.OID || 1
const { value, onChange, schema, addons } = props
const { disabled, accountName, fieldshine, siteJurisdiction, sql, isMultiple, presetValue, placeholder } = schema
const { disabled, accountName, fieldshine, siteFilter, sql, isMultiple, presetValue, placeholder } = schema
const [params, setParams] = useState({ info: '', total: 0, pageIndex: 1, pageSize: 20 })
const [loading, setLoading] = useState(false)
......@@ -68,8 +68,8 @@ const AccountSelector = (props) => {
const getPageList = async (outParams = {}) => {
let queryWheres = []
if (siteJurisdiction) {
const { code, data } = await getStationListByUserID(...[userID, window.globalConfig.client, false])
if (siteFilter) {
const { code, data } = await getStationListByUserID(...[userID, false])
if (code === 0) {
queryWheres = [
{
......@@ -99,6 +99,8 @@ const AccountSelector = (props) => {
setKeys(rows.map(v => v.ID))
setParams({ ...params, ...outParams, total: data.totalCount })
}
} else {
message.error(msg)
}
setLoading(false)
}
......@@ -118,9 +120,9 @@ const AccountSelector = (props) => {
Object.keys(addons.formData[child]).forEach(sun => {
fieldshine.forEach(v => {
if (sun === v.toField) {
const schema = form.getSchemaByPath(`${child}.${sun}`)
const schema = addons.getSchemaByPath(`${child}.${sun}`)
if (schema.widget === 'fileUpload') {
form.setSchemaByPath(`${child}.${sun}`, { ...schema, otherFile: row[v.fromField] })
addons.setSchemaByPath(`${child}.${sun}`, { ...schema, otherFile: row[v.fromField] })
} else {
addons.setValue(`${child}.${sun}`, row[v.fromField] || '')
}
......@@ -131,7 +133,7 @@ const AccountSelector = (props) => {
} else {
let array = dataSource.filter(v => keys.includes(v.ID))
if (array.length) {
let rowValues = array.map(v => v[fieldshine[0].fromField]).join(',')
let rowValues = array.map(v => v[fieldshine[0].fromField]).filter(v => v).join(',')
onChange(rowValues)
}
}
......@@ -151,10 +153,11 @@ const AccountSelector = (props) => {
return (
<div className={styles.AccountSelector}>
<Input
placeholder={placeholder}
placeholder={!disabled ? placeholder : null}
value={value}
onClick={() => iconClick()}
addonAfter={!disabled ? addonAfter : null}
disabled={disabled}
/>
<Modal
onCancel={() => setVisible(false)}
......@@ -182,7 +185,7 @@ const AccountSelector = (props) => {
size="small"
scroll={{ x: 1500, y: 400 }}
rowSelection={{
type: isMultiple ? 'checkbox' : 'radio',
type: isMultiple && fieldshine.length === 1 ? 'checkbox' : 'radio',
selectedRowKeys: keys,
fixed: 'left',
onChange: rowChange
......
......@@ -4,8 +4,6 @@ import { LoadUnattachedTables } from '../../../../../apis/process'
const TableNames = (props) => {
console.log('props11', props)
const { value, schema, onChange } = props
const [options, setOptions] = useState([])
......
import React, { useContext, useMemo, useState } from 'react'
import { Input, Select, message } from 'antd'
import { LoadTableFields, ReloadTableFields } from '../../../../../apis/process'
// import { GlobalStore } from '../../../../FormDesigner'
const field = [
"处理站点",
"上报人名称",
"上报人部门",
"上报时间",
"现场图片",
"现场录音",
"来源",
"微信探漏是否维修",
"表具服务流水号",
"维修状态",
"维修费用状态",
"用户编号",
"联系人",
"联系电话",
"故障类型",
"是否探到漏点",
"具体位置_门牌号",
"情况描述",
"图片",
"要求处理时间",
"附件_图片",
"探漏人员",
"配合人员",
"创建星期数",
"创建小时数",
"创建分钟数",
"工单编号",
"是否为工作日",
"分支环节1",
"分支环节2",
"服务人员",
"派单提交时间",
"派单状态数字",
"是否接单",
"接单提交时间",
"现场是否需要恢复",
"是否收费",
"管道资产",
"现场情况",
"无需维修原因",
"处理前图片",
"确认当前位置",
"经度",
"纬度",
"是否关阀",
"关闭阀门位置及大小",
"维修管径_DN",
"处理后照片",
"打开阀门位置及大小",
"实收费用",
"维修材料清单",
"缴费照片留存",
"备注",
"维修提交时间",
"维修状态数字",
"恢复前照片",
"恢复提交时间",
"是否已恢复",
"恢复后照片",
"恢复费用要素",
"恢复使用材料拍照",
"恢复费用",
"恢复状态数字",
"维修费用要素",
"计算费用",
"派单耗时",
"接单耗时",
"维修耗时",
"恢复耗时",
"派单耗时_分",
"接单耗时_分",
"维修耗时_分",
"恢复耗时_分"
]
const FieldNames = (props) => {
const { value, onChange, addons } = props
console.log('props', props)
const [fieldName, setFieldName] = useState([])
// const { tableName } = useContext(GlobalStore)
......
......@@ -4,7 +4,8 @@ import { LoadLedgers } from '../../../../../apis/process'
const AccountName = (props) => {
const { value, onChange } = props
const { value, onChange, schema, addons } = props
const { name } = addons.formData
const [options, setOptions] = useState([])
const onFocus = async () => {
......@@ -20,12 +21,19 @@ const AccountName = (props) => {
}
}
const selectChange = (value) => {
onChange(value)
if (name === '台账选择器') {
addons.setValues({ ...addons.formData, fieldshine: [] })
}
}
return (
<Select
value={value}
onFocus={onFocus}
showSearch
onChange={value => onChange(value)}
onChange={selectChange}
>
{
options.map(v => {
......
......@@ -8,10 +8,8 @@ const { TreeNode } = TreeSelect
const Fieldshine = (props) => {
console.log('props', props)
const { addons, onChange, value } = props
const { accountName } = addons.formData
const { accountName, tableNameParent } = addons.formData
const [form] = Form.useForm()
const [visible, setVisible] = useState(false)
......@@ -19,9 +17,17 @@ const Fieldshine = (props) => {
const [toField, setToField] = useState([])
const onOk = () => {
const { field } = form.getFieldsValue()
onChange(field)
setVisible(false)
form
.validateFields()
.then((values) => {
// form.resetFields();
const { field } = form.getFieldsValue()
onChange(field)
setVisible(false)
})
.catch((info) => {
console.log('Validate Failed:', info)
})
}
const inputClick = async () => {
......@@ -29,9 +35,7 @@ const Fieldshine = (props) => {
return message.info('请选择台账名称')
}
const req1 = QueryFields(accountName)
console.log(addons, addons.getValue('root'))
const req2 = ReloadTableFields({ tableName: '事件_测试02' })
// const req3 = QueryFields(accountName)
const req2 = ReloadTableFields({ tableName: tableNameParent })
const [res1, res2] = await Promise.all([req1, req2])
if (res1.code === 0) {
if (Array.isArray(res1.data)) {
......@@ -47,13 +51,10 @@ const Fieldshine = (props) => {
} else {
message.error(res2.msg)
}
form.setFieldsValue({ field: value })
setVisible(true)
}
// useEffect(() => {
// addons.setValue(addons.dataPath, [])
// }, [accountName])
return (
<div className={styles.fieldshine}>
<Input
......@@ -88,8 +89,8 @@ const Fieldshine = (props) => {
rules={[
{
required: true,
message: 'Missing first name',
},
message: '来源字段必填',
}
]}
>
<TreeSelect
......@@ -113,8 +114,18 @@ const Fieldshine = (props) => {
rules={[
{
required: true,
message: 'Missing last name',
message: '目标字段必填',
},
{
validator: (rules, value, callback) => {
const { field } = form.getFieldsValue()
let toFields = Array.from(new Set([...field.map(v => v.toField)]))
if (toFields.length !== field.length) {
return Promise.reject('目标字段不能重复!')
}
return Promise.resolve()
}
}
]}
>
<TreeSelect
......@@ -144,7 +155,6 @@ const Fieldshine = (props) => {
</Form.List>
</Form>
</Modal>
</div>
)
......
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