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

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

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