Commit 0b114fb4 authored by 彭俊龙's avatar 彭俊龙

映射字段增加固定参数,用户ID和用户名称

parent 7938b9ea
{ {
"name": "panda-xform", "name": "panda-xform",
"version": "6.10.80", "version": "6.10.84",
"description": "6.10.80 部门选择支持选择父级自动带入子级", "description": "6.10.84 部门选择支持选择父级自动带入子级",
"keywords": [ "keywords": [
"panda-xform" "panda-xform"
], ],
......
...@@ -83,9 +83,11 @@ const ValueEdit = (props) => { ...@@ -83,9 +83,11 @@ const ValueEdit = (props) => {
const dealSelect = ()=>{ const dealSelect = ()=>{
const random = Math.floor(Math.random() * (300 - 100 + 1)) + 100;
const random1 = Math.floor(Math.random() * (500 - 300 + 1)) + 300;
setTimeout(()=>{ setTimeout(()=>{
getTableData(); getTableData();
}, 100) }, fieldTableKey ? random1 : random)
if(fieldTableKey){ if(fieldTableKey){
eventEmitter.on(`${record.ID}_event`, (val)=> dealParentData(val)) eventEmitter.on(`${record.ID}_event`, (val)=> dealParentData(val))
......
...@@ -255,7 +255,7 @@ const TablePack = (props, ref) => { ...@@ -255,7 +255,7 @@ const TablePack = (props, ref) => {
}), }),
render: (value, record) => { render: (value, record) => {
let jsonData = json[fieldName] let jsonData = json[fieldName]
if(jsonData.hasOwnProperty('fieldName')){ if(jsonData?.['fieldName']){
jsonData['_fieldName'] = jsonData['fieldName'] jsonData['_fieldName'] = jsonData['fieldName']
} }
let props = { let props = {
......
...@@ -26,6 +26,7 @@ const getFormDataObj = (formData) => { ...@@ -26,6 +26,7 @@ const getFormDataObj = (formData) => {
const RelationForm = (props) => { const RelationForm = (props) => {
const userID = window?.globalConfig?.userInfo?.OID || 1 const userID = window?.globalConfig?.userInfo?.OID || 1
const fullName = window?.globalConfig?.userInfo?.fullName || ''
const codes = window?.pandaXform?.codes || { 工单编号: '', 事件编号: '', } const codes = window?.pandaXform?.codes || { 工单编号: '', 事件编号: '', }
const { value, onChange, schema, addons } = props const { value, onChange, schema, addons } = props
const { const {
...@@ -164,7 +165,13 @@ const RelationForm = (props) => { ...@@ -164,7 +165,13 @@ const RelationForm = (props) => {
if (Array.isArray(mappedField)) { if (Array.isArray(mappedField)) {
let formDataObj = getFormDataObj(addons?.formData) let formDataObj = getFormDataObj(addons?.formData)
mappedField.forEach(v => { mappedField.forEach(v => {
queryWheres.push({ field: v.toField, type: '等于', value: codes[v.fromField] || formDataObj[v.fromField] }) let value = codes[v.fromField] || formDataObj[v.fromField]
if(v.fromField === '用户ID'){
value = userID
}else if(v.fromField === '用户名称'){
value = fullName
}
queryWheres.push({ field: v.toField, type: '等于', value })
}) })
} }
let relationForm = addons.getValue('relationForm') || { configs: [], data: [], table: [] } let relationForm = addons.getValue('relationForm') || { configs: [], data: [], table: [] }
...@@ -404,7 +411,7 @@ const RelationForm = (props) => { ...@@ -404,7 +411,7 @@ const RelationForm = (props) => {
} }
}) })
} }
} else { } else if(otherSource?.field?.length > 0) {
let fromField = otherSource?.field?.find(j => j.toField === s)?.fromField let fromField = otherSource?.field?.find(j => j.toField === s)?.fromField
obj[s] = v[fromField] || '' obj[s] = v[fromField] || ''
values.push({ fieldName: s, fieldValue: v[fromField] || '' }) values.push({ fieldName: s, fieldValue: v[fromField] || '' })
...@@ -453,7 +460,6 @@ const RelationForm = (props) => { ...@@ -453,7 +460,6 @@ const RelationForm = (props) => {
if (otherSource?.sql && addons) { if (otherSource?.sql && addons) {
const sql = dealSql(otherSource.sql) const sql = dealSql(otherSource.sql)
setParamsOther({ ...paramsOther, condition: window.btoa(encodeURIComponent(sql)) }) setParamsOther({ ...paramsOther, condition: window.btoa(encodeURIComponent(sql)) })
console.log(paramsOther, sql, 'paramsOther');
} }
}, [otherSource]) }, [otherSource])
......
import React, { useEffect, useMemo, useRef, useState } from 'react' import React, { useEffect, useMemo, useRef, useState } from 'react'
import styles from './index.less' import styles from './index.less'
import { Upload, Button, message, Tabs } from 'antd' import { Upload, Button, message, Tabs, Input } from 'antd'
import { UploadOutlined, FileOutline, ArrowDownOutlined } from '@ant-design/icons' import { UploadOutlined, FileOutline, ArrowDownOutlined } from '@ant-design/icons'
import FileViewer from 'react-file-viewer' import FileViewer from 'react-file-viewer'
import Viewer from 'react-viewer' import Viewer from 'react-viewer'
...@@ -74,6 +74,12 @@ const getFileType = (fileName) => { ...@@ -74,6 +74,12 @@ const getFileType = (fileName) => {
if (fileName.includes("MOV")) { if (fileName.includes("MOV")) {
return "MOV"; return "MOV";
} }
if (fileName.includes("txt")) {
return "txt";
}
if (fileName.includes("csv")) {
return "csv";
}
} }
return null return null
} }
...@@ -90,7 +96,7 @@ const FileUpload = (props) => { ...@@ -90,7 +96,7 @@ const FileUpload = (props) => {
const [showFile, setShowFile] = useState({ fileType: '', filePath: '' }) const [showFile, setShowFile] = useState({ fileType: '', filePath: '' })
const [workbook, setWorkbook] = useState({ SheetNames: [] }) const [workbook, setWorkbook] = useState({ SheetNames: [] })
const [activeIndex, setActiveIndex] = useState(1) const [activeIndex, setActiveIndex] = useState(1)
const [txtContent, setTxtContent] = useState('');
const images = useMemo(() => { const images = useMemo(() => {
let array = [] let array = []
showList.forEach(v => { showList.forEach(v => {
...@@ -159,6 +165,7 @@ const FileUpload = (props) => { ...@@ -159,6 +165,7 @@ const FileUpload = (props) => {
onPreview: async (file) => { onPreview: async (file) => {
if (!preview) return message.info('该附件禁止预览') if (!preview) return message.info('该附件禁止预览')
let fileType = getFileType(file.name) let fileType = getFileType(file.name)
console.log(fileType, file.url, '文件类型');
setShowFile({ name: file.name, fileType: fileType, filePath: file.url }) setShowFile({ name: file.name, fileType: fileType, filePath: file.url })
if (fileType) { if (fileType) {
if (['jpg', 'png', 'svg', 'jpeg'].includes(fileType)) { if (['jpg', 'png', 'svg', 'jpeg'].includes(fileType)) {
...@@ -166,7 +173,7 @@ const FileUpload = (props) => { ...@@ -166,7 +173,7 @@ const FileUpload = (props) => {
setActiveIndex(index) setActiveIndex(index)
setImgVisible(true) setImgVisible(true)
} else { } else {
if (['xlsx', 'xls'].includes(fileType)) { if (['xlsx', 'xls', 'csv'].includes(fileType)) {
downloadFile(file.sourcePath) downloadFile(file.sourcePath)
.then(response => response.arrayBuffer()) .then(response => response.arrayBuffer())
.then(buffer => { .then(buffer => {
...@@ -180,6 +187,13 @@ const FileUpload = (props) => { ...@@ -180,6 +187,13 @@ const FileUpload = (props) => {
console.log(sheetName, jsonData) console.log(sheetName, jsonData)
}) })
}) })
}else if(['txt'].includes(fileType)){
// 处理 .txt 文件预览
downloadFile(file.sourcePath)
.then(response => response.text())
.then(text => {
setTxtContent(text);
});
} }
// if (fileType === 'ofd') { // if (fileType === 'ofd') {
...@@ -206,7 +220,16 @@ const FileUpload = (props) => { ...@@ -206,7 +220,16 @@ const FileUpload = (props) => {
</div> </div>
) )
} }
if (['xlsx', 'xls'].includes(showFile.fileType)) { if(['txt'].includes(showFile.fileType)){
return (
<Input.TextArea
value={txtContent}
readOnly
style={{ width: '100%', height: '100%' }}
/>
)
}
if (['xlsx', 'xls', 'csv'].includes(showFile.fileType)) {
return ( return (
<div> <div>
<Tabs> <Tabs>
......
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
width: 45px; width: 45px;
height: 45px; height: 45px;
margin: 0 auto; margin: 0 auto;
&[type='txt'],
&[type='通用'] { &[type='通用'] {
background: url('@{imgSrc}/通用.png'); background: url('@{imgSrc}/通用.png');
background-size: 100% 100%; background-size: 100% 100%;
...@@ -32,6 +33,7 @@ ...@@ -32,6 +33,7 @@
background-size: 100% 100%; background-size: 100% 100%;
} }
&[type='xlsx'], &[type='xlsx'],
&[type='csv'],
&[type='xls'] { &[type='xls'] {
background: url('@{imgSrc}/Excel.png'); background: url('@{imgSrc}/Excel.png');
background-size: 100% 100%; background-size: 100% 100%;
......
...@@ -96,7 +96,7 @@ const MappedField = (props) => { ...@@ -96,7 +96,7 @@ const MappedField = (props) => {
showCheckedStrategy showCheckedStrategy
> >
<TreeNode value='内置字段' title='内置字段' disabled> <TreeNode value='内置字段' title='内置字段' disabled>
{['工单编号', '事件编号', '事件名称'].map(s => <TreeNode value={s} title={s} key={s} />)} {['工单编号', '事件编号', '事件名称', '用户ID', '用户名称'].map(s => <TreeNode value={s} title={s} key={s} />)}
</TreeNode> </TreeNode>
<TreeNode value='附加字段' title='附加字段' disabled> <TreeNode value='附加字段' title='附加字段' disabled>
{ {
......
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