提交 f41d6010 authored 作者: wtj's avatar wtj

新增表单列表附件查看功能

上级 a16b806b
...@@ -32,6 +32,9 @@ import SearchInfo from '../../App/SearchInfo'; ...@@ -32,6 +32,9 @@ import SearchInfo from '../../App/SearchInfo';
import {Base16Encode} from "../../Base16/index"; import {Base16Encode} from "../../Base16/index";
import baseX from 'base-x' import baseX from 'base-x'
import {isEmpty} from 'lodash' import {isEmpty} from 'lodash'
import FilePreview from "@/webPublic/one_stop_public/filePreview";
import {queryApiActionPath} from "@/webPublic/one_stop_public/utils/queryConfig";
import UploadCom from "@/components/libs/UploadCom";
const BASE16 = '0123456789abcdef' const BASE16 = '0123456789abcdef'
const bs16 = baseX(BASE16) const bs16 = baseX(BASE16)
const FormItem = Form.Item; const FormItem = Form.Item;
...@@ -232,6 +235,24 @@ class FormList extends React.Component { ...@@ -232,6 +235,24 @@ class FormList extends React.Component {
// } // }
}; };
isJSON = (str) => {
if (typeof str == 'string') {
try {
var obj = JSON.parse(str);
if (typeof obj == 'object' && obj) {
return true;
} else {
return false;
}
} catch (e) {
console.log('error:' + str + '!!!' + e);
return false;
}
}
console.log('这不是个字符串')
}
delete = record => { delete = record => {
//找出主键 //找出主键
let Keys = {}; let Keys = {};
...@@ -361,7 +382,7 @@ class FormList extends React.Component { ...@@ -361,7 +382,7 @@ class FormList extends React.Component {
const b = nextProps.value||{} const b = nextProps.value||{}
const a = this.props.value||{} const a = this.props.value||{}
if(JSON.stringify(a)!=JSON.stringify(b)){ if(JSON.stringify(a)!=JSON.stringify(b)){
const params = { const params = {
...@@ -372,7 +393,7 @@ class FormList extends React.Component { ...@@ -372,7 +393,7 @@ class FormList extends React.Component {
if(nextProps.value.columns!=null&&nextProps.value.columns.length>0){ if(nextProps.value.columns!=null&&nextProps.value.columns.length>0){
this.columns=nextProps.value.columns this.columns=nextProps.value.columns
} }
this.custom=Base16Encode(JSON.stringify(b)) this.custom=Base16Encode(JSON.stringify(b))
if( nextProps.value.getPage){ if( nextProps.value.getPage){
this.getPage(params,null,nextProps.value.getPage); this.getPage(params,null,nextProps.value.getPage);
...@@ -440,7 +461,27 @@ class FormList extends React.Component { ...@@ -440,7 +461,27 @@ class FormList extends React.Component {
} }
}else if(datas[t].name.indexOf("process_status")>-1){ }else if(datas[t].name.indexOf("process_status")>-1){
column.render=(val)=>val?(val==="0"?"审核通过":"审核未通过"):null column.render=(val)=>val?(val==="0"?"审核通过":"审核未通过"):null
}else { }else if(datas[t].extendTypeId&&datas[t].extendTypeId.indexOf("file")>-1){ //特殊处理附件
column.render =( val) =>{
if(this.isJSON(val)){
val = JSON.parse(val);
let files = val.files;
let xx =( <ul>
{files.map((f, index2) => {
return <li key={index2}><FilePreview
path={queryApiActionPath() + f.path}
pathName={f.name}
/></li>
}
)}
</ul>
)
return xx;
}else {
return val;
}
}
}else{
column.render=(val)=>val&&val.length>100? <Tooltip title={val} overlayStyle={{width:1000}}> column.render=(val)=>val&&val.length>100? <Tooltip title={val} overlayStyle={{width:1000}}>
<span style={{width:column.width||200,display:"block", wordBreak:"keep-all",whiteSpace:"nowrap", overflow:"hidden", textOverflow:"ellipsis"}}>{val}</span> <span style={{width:column.width||200,display:"block", wordBreak:"keep-all",whiteSpace:"nowrap", overflow:"hidden", textOverflow:"ellipsis"}}>{val}</span>
</Tooltip>:val </Tooltip>:val
...@@ -766,7 +807,18 @@ class FormList extends React.Component { ...@@ -766,7 +807,18 @@ class FormList extends React.Component {
</FormItem> </FormItem>
); );
} else if(isQuery&&item.isGroupQuery!=null&&item.isGroupQuery){ //如果是查询 并且是组合查询 } else if(item.extendTypeId&&item.extendTypeId.indexOf("file")>-1){
//特殊处理附件 如果是查询就 跳过
if(isQuery) return ;
return (
<FormItem labelCol={labelCol} wrapperCol={wrapperCol} label={item.title} key={item.id}>
{form.getFieldDecorator(item.name, {
initialValue: formData == null ? '' : (formData[item.name]&&this.isJSON(formData[item.name])?JSON.parse(formData[item.name]):null),
rules: [{ required: !item.isNull }],
})(<UploadCom />)}
</FormItem>
);
} else if(isQuery&&item.isGroupQuery!=null&&item.isGroupQuery){ //如果是查询 并且是组合查询
const ops = groups[item.id + ''] || [] const ops = groups[item.id + ''] || []
return ( return (
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论