提交 4b542b71 authored 作者: 钟是志's avatar 钟是志

流程发起增加回调函数

上级 5e2391ef
import React from "react"; import React from "react";
import { Button, Icon, message, Modal, Upload } from "antd"; import {Button, Icon, message, Modal, Upload} from "antd";
import { queryApiActionPath } from "../utils/queryConfig"; import {queryApiActionPath} from "../utils/queryConfig";
import config from "@/webPublic/one_stop_public/config"; import config from "@/webPublic/one_stop_public/config";
import styles from "./style.less"; import styles from "./style.less";
import UploadComDiyForQnZy from "@/webPublic/one_stop_public/libs/UploadComDiyForQnZy"; import UploadComDiyForQnZy from "@/webPublic/one_stop_public/libs/UploadComDiyForQnZy";
export function checkIsImage(path){ export function checkIsImage(path) {
if(!path){ if (!path) {
return false; return false;
} }
let p = path.toLowerCase(); let p = path.toLowerCase();
let find = ['.jpg','.png', '.jpeg', '.bmp', '.gif', '.bmp', '.svg'].find((x) => { let find = ['.jpg', '.png', '.jpeg', '.bmp', '.gif', '.bmp', '.svg'].find((x) => {
return path.indexOf(x) > -1; return path.indexOf(x) > -1;
}); });
return !!find; return !!find;
...@@ -32,8 +32,18 @@ class UploadCom extends React.Component { ...@@ -32,8 +32,18 @@ class UploadCom extends React.Component {
this.state = { this.state = {
files: value.files, files: value.files,
previewVisible: false, previewVisible: false,
previewImage: "" previewImage: "",
}; };
console.log(props);
if (props.json?.otherProps) {
this.otherProps = props.json?.otherProps;
try {
this.otherProps = new Function(this.otherProps);
console.log(this.otherProps);
} catch (e) {
}
}
} }
triggerChange = (changedValue) => { triggerChange = (changedValue) => {
...@@ -56,11 +66,11 @@ class UploadCom extends React.Component { ...@@ -56,11 +66,11 @@ class UploadCom extends React.Component {
if (info.file.status === "done") { if (info.file.status === "done") {
message.success(`${info.file.name} 上传成功`); message.success(`${info.file.name} 上传成功`);
const files = this.state.files; const files = this.state.files;
files.push({ path: info.file.response, name: info.file.name }); files.push({path: info.file.response, name: info.file.name});
if (!("value" in this.props)) { if (!("value" in this.props)) {
this.setState({ files }); this.setState({files});
} }
this.triggerChange({ files }); this.triggerChange({files});
} else if (info.file.status === "error") { } else if (info.file.status === "error") {
message.error(`${info.file.name} 上传失败`); message.error(`${info.file.name} 上传失败`);
} }
...@@ -74,14 +84,14 @@ class UploadCom extends React.Component { ...@@ -74,14 +84,14 @@ class UploadCom extends React.Component {
} }
} }
if (!("value" in this.props)) { if (!("value" in this.props)) {
this.setState({ files }); this.setState({files});
} }
this.triggerChange({ files }); this.triggerChange({files});
}; };
render() { render() {
const { files, previewVisible, previewImage } = this.state; const {files, previewVisible, previewImage} = this.state;
const { isMultiple, accept, btnName, disabled } = this.props; const {isMultiple, accept, btnName, disabled} = this.props;
const props = { const props = {
name: "file", name: "file",
multiple: isMultiple, multiple: isMultiple,
...@@ -96,19 +106,19 @@ class UploadCom extends React.Component { ...@@ -96,19 +106,19 @@ class UploadCom extends React.Component {
<Upload {...props} disabled={disabled}> <Upload {...props} disabled={disabled}>
{!disabled && ( {!disabled && (
<Button> <Button>
<Icon type="upload" /> <Icon type="upload"/>
{btnName ? btnName : "上传附件"} {btnName ? btnName : "上传附件"}
</Button> </Button>
)} )}
</Upload> </Upload>
<ul style={{ paddingLeft: 8, display: "flex" }}> <ul style={{paddingLeft: 8, display: "flex"}}>
{(files || []).map((f) => { {(files || []).map((f) => {
if (f.path && checkIsImage(f.path)) { if (f.path && checkIsImage(f.path)) {
return ( return (
<li key={f.path} className={styles.preview_img}> <li key={f.path} className={styles.preview_img}>
<div className={styles.preview_div}> <div className={styles.preview_div}>
<img <img
style={{ width: '100px', height: 'auto' }} style={{width: '100px', height: 'auto'}}
className={styles.img} className={styles.img}
src={queryApiActionPath() + f.path} src={queryApiActionPath() + f.path}
/> />
...@@ -121,12 +131,12 @@ class UploadCom extends React.Component { ...@@ -121,12 +131,12 @@ class UploadCom extends React.Component {
previewImage: queryApiActionPath() + f.path previewImage: queryApiActionPath() + f.path
}); });
}}> }}>
<Icon type="eye" className={styles.icon_eye} /> <Icon type="eye" className={styles.icon_eye}/>
</div> </div>
</div> </div>
{!disabled && ( {!disabled && (
<Icon <Icon
style={{ marginLeft: 10 }} style={{marginLeft: 10}}
type="delete" type="delete"
onClick={this.remove.bind(this, f.path)} onClick={this.remove.bind(this, f.path)}
/> />
...@@ -141,7 +151,7 @@ class UploadCom extends React.Component { ...@@ -141,7 +151,7 @@ class UploadCom extends React.Component {
</a>{" "} </a>{" "}
{!disabled && ( {!disabled && (
<Icon <Icon
style={{ marginLeft: 10 }} style={{marginLeft: 10}}
type="delete" type="delete"
onClick={this.remove.bind(this, f.path)} onClick={this.remove.bind(this, f.path)}
/> />
...@@ -153,10 +163,10 @@ class UploadCom extends React.Component { ...@@ -153,10 +163,10 @@ class UploadCom extends React.Component {
<Modal <Modal
visible={previewVisible} visible={previewVisible}
footer={null} footer={null}
onCancel={() => this.setState({ previewVisible: false })} onCancel={() => this.setState({previewVisible: false})}
width={'90vw'} width={'90vw'}
> >
<img alt="example" style={{ width: "100%", height:'auto' }} src={previewImage} /> <img alt="example" style={{width: "100%", height: 'auto'}} src={previewImage}/>
</Modal> </Modal>
</div> </div>
); );
......
export function submitProcessData({ payload, item, data }) { // export function submitProcessData({ payload, item, data }) {
let postData = { // let postData = {
...payload, // ...payload,
buttonInfo: item, // buttonInfo: item,
ssxRemark: // ssxRemark:
'examineMap 和 taskForm 都是json字符串 通过修改 examineMap, taskForm中的值 达到改变提交记录的效果', // 'examineMap 和 taskForm 都是json字符串 通过修改 examineMap, taskForm中的值 达到改变提交记录的效果',
apiData: data, // apiData: data,
taskFormKey: data.taskFormKey, // taskFormKey: data.taskFormKey,
}; // };
return postData; // return postData;
} // }
export function callbackSubmitData(infoData) { export function callbackSubmitData(infoData) {
console.log(infoData); console.log(infoData);
...@@ -26,3 +26,16 @@ export function callbackSubmitData(infoData) { ...@@ -26,3 +26,16 @@ export function callbackSubmitData(infoData) {
} }
return infoData; return infoData;
} }
export function callbackApplyData(infoData) { // 流程发起的回调函数
console.log(infoData);
if (window.callbackApplyDataInfoZhiYong && typeof window.callbackApplyDataInfoZhiYong === 'function') {
infoData = window.callbackApplyDataInfoZhiYong({ // 返回新的值就行了.
postData: infoData, //
});
if (typeof infoData === 'object') {
delete infoData.userNowInfo;
}
}
return infoData;
}
...@@ -2940,6 +2940,7 @@ export default class tableCom extends Component { ...@@ -2940,6 +2940,7 @@ export default class tableCom extends Component {
isMultiple={json.isMultiple} isMultiple={json.isMultiple}
accept={json.accept} accept={json.accept}
btnName={json.btnName} btnName={json.btnName}
json={json}
disabled={disabled || isPreview} disabled={disabled || isPreview}
/>, />,
); );
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论