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

贵建宿管从 2021年6月28日13:41:11 的黔南宿管的分支拉取

并把辅导员 全部改成班主任
上级 55567b83
......@@ -10,59 +10,57 @@ import { getDefaultValues } from '../../destruction';
import { message } from 'antd';
const getIndex = (arr, name) => {
return arr.findIndex((x) => {
return x.name === name;
});
return arr.findIndex((x) => {
return x.name === name;
});
};
const GJLZJXJApply = (WrappedComponent) =>
class extends Component {
diyFunction = () => {
this.instanceComponent.handleButtonSet = () => {
let that = this.instanceComponent;
const { addFields, workId, tableInfo } = that.state;
const bankNumIndex = getIndex(addFields, '银行卡号');
const defaultValues = getDefaultValues(addFields, tableInfo);
const beforeSubmit = (data, ModalFormComponent) => {
const bankKey = addFields[bankNumIndex].key;
if (data[bankKey] && data[bankKey].replace(/\s/g, '').length !== 19) {
message.warning('请输入正确的19位银行卡卡号');
return false;
}
return data;
};
return [
{
type: 'add',
name: '申请',
component: 'ModalForm',
workId,
fields: addFields,
modalWidth: 800,
values: {
...defaultValues,
},
beforeSubmit,
nameSpan: { big: 6, small: 6 },
fileSpan: { big: 1, small: 1 },
},
];
};
};
const GJLZJXJApply = WrappedComponent => class extends Component {
componentDidMount() {
console.log(this.instanceComponent);
this.diyFunction();
}
diyFunction = () => {
this.instanceComponent.handleButtonSet = () => {
let that = this.instanceComponent;
const { addFields, workId, tableInfo } = that.state;
const bankNumIndex = getIndex(addFields, '银行卡号');
const defaultValues = getDefaultValues(addFields, tableInfo);
const beforeSubmit = (data, ModalFormComponent) => {
const bankKey = addFields[bankNumIndex].key;
if(data[bankKey] && data[bankKey].replace(/\s/g,"").length !== 19){
message.warning('请输入正确的19位银行卡卡号');
return false;
}
return data;
};
return [
{
type: 'add',
name: '申请',
component: 'ModalForm',
workId,
fields: addFields,
modalWidth: 800,
values: {
...defaultValues,
},
beforeSubmit,
nameSpan: { big: 6, small: 6 },
fileSpan: { big: 1, small: 1 },
},
];
};
};
componentDidMount() {
console.log(this.instanceComponent);
this.diyFunction();
}
render() {
return (
<WrappedComponent
ref={instanceComponent => this.instanceComponent = instanceComponent}
/>
);
}
};
render() {
return (
<WrappedComponent
ref={(instanceComponent) => (this.instanceComponent = instanceComponent)}
/>
);
}
};
export default KNXSRDApply(ApplyPage); // 高阶组件
......@@ -10,94 +10,91 @@ import { getDefaultValues } from '../../destruction';
import { deepCopy } from '@/baseComponent/utils';
const getIndex = (arr, name) => {
return arr.findIndex((x) => {
return x.name === name;
});
return arr.findIndex((x) => {
return x.name === name;
});
};
const KNXSJTQKSQ = (WrappedComponent) =>
class extends Component {
diyFunction = () => {
this.instanceComponent.handleButtonSet = () => {
let that = this.instanceComponent;
const { addFields, workId, tableInfo } = that.state;
const KNXSJTQKSQ = WrappedComponent => class extends Component {
const familyTypeIndex = getIndex(addFields, '家庭类型');
const fileIndex = getIndex(addFields, '家庭类型证明材料');
const famliyMemberIndex = getIndex(addFields, '家庭成员(不含自己)');
const famliyMoneyIndex = getIndex(addFields, '家庭人均年收入(元)');
const familyNumberIndex = getIndex(addFields, '家庭人口数');
diyFunction = () => {
this.instanceComponent.handleButtonSet = () => {
let that = this.instanceComponent;
const { addFields, workId, tableInfo } = that.state;
const defaultValues = getDefaultValues(addFields, tableInfo);
const diyFormStateChange = (value, key, ModalFormComponent) => {
let oldValue = ModalFormComponent.state.formValues;
if (typeof value === 'object') {
oldValue[key] = deepCopy(value);
} else {
oldValue[key] = value;
}
if (familyTypeIndex >= 0 && key === addFields[familyTypeIndex].key) {
// 改变家庭类型时.
let testOne = value.substring(0, 1);
if ([2, 3, 4, 5, 6, 7].indexOf(Number(testOne)) > -1) {
// 如果学生勾选了项目234567,就必须要上传附件;
addFields[fileIndex].required = true;
} else {
addFields[fileIndex].required = false;
}
that.setState({ addFields });
}
const familyTypeIndex = getIndex(addFields, '家庭类型');
const fileIndex = getIndex(addFields, '家庭类型证明材料');
const famliyMemberIndex = getIndex(addFields, '家庭成员(不含自己)');
const famliyMoneyIndex = getIndex(addFields, '家庭人均年收入(元)');
const familyNumberIndex = getIndex(addFields, '家庭人口数');
if (famliyMemberIndex >= 0 && key === addFields[famliyMemberIndex].key) {
// 改变家庭成员时
let money = 0;
const famliyMemberFileds = addFields[famliyMemberIndex].componentProps.thisFields;
const onePersonIndex = getIndex(famliyMemberFileds, '年收入(元)');
for (let item of value) {
money = money + item[famliyMemberFileds[onePersonIndex].key];
}
oldValue[addFields[famliyMoneyIndex].key] = parseInt(money / (value.length + 1), 10); // 计算家庭平均年收入
oldValue[addFields[familyNumberIndex].key] = value.length + 1; // 计算家庭人数
}
const defaultValues = getDefaultValues(addFields, tableInfo);
const diyFormStateChange = (value, key, ModalFormComponent) => {
ModalFormComponent.setState({
formValues: oldValue,
});
};
return [
{
type: 'add',
name: '申请',
component: 'ModalForm',
diyFormStateChange,
workId,
fields: addFields,
modalWidth: 800,
values: {
...defaultValues,
},
nameSpan: { big: 6, small: 6 },
fileSpan: { big: 1, small: 1 },
},
];
};
};
let oldValue = ModalFormComponent.state.formValues;
if (typeof value === 'object') {
oldValue[key] = deepCopy(value);
} else {
oldValue[key] = value;
}
componentDidMount() {
console.log(this.instanceComponent);
this.diyFunction();
}
if (familyTypeIndex >= 0 && key === addFields[familyTypeIndex].key) { // 改变家庭类型时.
let testOne = value.substring(0, 1);
if ([2, 3, 4, 5, 6, 7].indexOf(Number(testOne)) > -1) {
// 如果学生勾选了项目234567,就必须要上传附件;
addFields[fileIndex].required = true;
} else {
addFields[fileIndex].required = false;
}
that.setState({ addFields });
}
if (famliyMemberIndex >= 0 && key === addFields[famliyMemberIndex].key) { // 改变家庭成员时
let money = 0;
const famliyMemberFileds = addFields[famliyMemberIndex].componentProps.thisFields;
const onePersonIndex = getIndex(famliyMemberFileds, '年收入(元)');
for (let item of value) {
money = money + item[famliyMemberFileds[onePersonIndex].key];
}
oldValue[addFields[famliyMoneyIndex].key] = parseInt(money / (value.length + 1 ), 10); // 计算家庭平均年收入
oldValue[addFields[familyNumberIndex].key] = value.length + 1; // 计算家庭人数
}
ModalFormComponent.setState({
formValues: oldValue,
});
};
return [
{
type: 'add',
name: '申请',
component: 'ModalForm',
diyFormStateChange,
workId,
fields: addFields,
modalWidth: 800,
values: {
...defaultValues,
},
nameSpan: { big: 6, small: 6 },
fileSpan: { big: 1, small: 1 },
},
];
};
};
componentDidMount() {
console.log(this.instanceComponent);
this.diyFunction();
}
render() {
return (
<WrappedComponent
ref={instanceComponent => this.instanceComponent = instanceComponent}
/>
);
}
};
render() {
return (
<WrappedComponent
ref={(instanceComponent) => (this.instanceComponent = instanceComponent)}
/>
);
}
};
export default KNXSJTQKSQ(ApplyPage); // 高阶组件
......@@ -10,59 +10,57 @@ import { getDefaultValues } from '../../destruction';
import { message } from 'antd';
const getIndex = (arr, name) => {
return arr.findIndex((x) => {
return x.name === name;
});
return arr.findIndex((x) => {
return x.name === name;
});
};
const KNXSRDApply = (WrappedComponent) =>
class extends Component {
diyFunction = () => {
this.instanceComponent.handleButtonSet = () => {
let that = this.instanceComponent;
const { addFields, workId, tableInfo } = that.state;
const bankNumIndex = getIndex(addFields, '银行卡号');
const defaultValues = getDefaultValues(addFields, tableInfo);
const beforeSubmit = (data, ModalFormComponent) => {
const bankKey = addFields[bankNumIndex].key;
if (data[bankKey] && data[bankKey].replace(/\s/g, '').length !== 19) {
message.warning('请输入正确的19位银行卡卡号');
return false;
}
return data;
};
return [
{
type: 'add',
name: '申请',
component: 'ModalForm',
workId,
fields: addFields,
modalWidth: 800,
values: {
...defaultValues,
},
beforeSubmit,
nameSpan: { big: 6, small: 6 },
fileSpan: { big: 1, small: 1 },
},
];
};
};
const KNXSRDApply = WrappedComponent => class extends Component {
componentDidMount() {
console.log(this.instanceComponent);
this.diyFunction();
}
diyFunction = () => {
this.instanceComponent.handleButtonSet = () => {
let that = this.instanceComponent;
const { addFields, workId, tableInfo } = that.state;
const bankNumIndex = getIndex(addFields, '银行卡号');
const defaultValues = getDefaultValues(addFields, tableInfo);
const beforeSubmit = (data, ModalFormComponent) => {
const bankKey = addFields[bankNumIndex].key;
if(data[bankKey] && data[bankKey].replace(/\s/g,"").length !== 19){
message.warning('请输入正确的19位银行卡卡号');
return false;
}
return data;
};
return [
{
type: 'add',
name: '申请',
component: 'ModalForm',
workId,
fields: addFields,
modalWidth: 800,
values: {
...defaultValues,
},
beforeSubmit,
nameSpan: { big: 6, small: 6 },
fileSpan: { big: 1, small: 1 },
},
];
};
};
componentDidMount() {
console.log(this.instanceComponent);
this.diyFunction();
}
render() {
return (
<WrappedComponent
ref={instanceComponent => this.instanceComponent = instanceComponent}
/>
);
}
};
render() {
return (
<WrappedComponent
ref={(instanceComponent) => (this.instanceComponent = instanceComponent)}
/>
);
}
};
export default KNXSRDApply(ApplyPage); // 高阶组件
......@@ -3,105 +3,114 @@
* 返回也是返回到上一个路由
* */
import { message } from "antd";
import React, { Fragment } from "react";
import { getToken } from "@/utils/authority";
import { message } from 'antd';
import React, { Fragment } from 'react';
import { getToken } from '@/utils/authority';
import PageHeaderWrapper from "@/components/PageHeaderWrapper";
import ButtonDiy from "@/baseComponent/ButtonDiy";
import Shell from "@/baseComponent/Shell";
import config from "@/config/config";
import router from "umi/router";
import PageHeaderWrapper from '@/components/PageHeaderWrapper';
import ButtonDiy from '@/baseComponent/ButtonDiy';
import Shell from '@/baseComponent/Shell';
import config from '@/config/config';
import router from 'umi/router';
export default class AffairPage extends React.Component {
constructor(props) {
super(props);
let state = this.props.location.state;
if(!state || !state.id){
console.error('无法获取流程id', 'JustApply.js');
}
this.state = {
workId: state.id,
init: {...state},
};
};
constructor(props) {
super(props);
let state = this.props.location.state;
if (!state || !state.id) {
console.error('无法获取流程id', 'JustApply.js');
}
this.state = {
workId: state.id,
init: { ...state },
};
}
componentDidMount() {
if (!getToken()) {
message.error("您的数据未同步,请联系管理员!");
return false;
}
window.addEventListener("message", (event) => { // 和Iframe页进行通迅
if (event.data === "returnList") {
this.returnList(true);
}
if (event && event.data && event.data.indexOf && event.data.indexOf("iframeHeight") > -1) {
let height = Number(event.data.split("-")[1]);
const iframe = document.getElementById("applyIframeId");
if (iframe) {
iframe.height = height;
}
}
}, false);
componentDidMount() {
if (!getToken()) {
message.error('您的数据未同步,请联系管理员!');
return false;
}
window.addEventListener(
'message',
(event) => {
// 和Iframe页进行通迅
if (event.data === 'returnList') {
this.returnList(true);
}
if (event && event.data && event.data.indexOf && event.data.indexOf('iframeHeight') > -1) {
let height = Number(event.data.split('-')[1]);
const iframe = document.getElementById('applyIframeId');
if (iframe) {
iframe.height = height;
}
}
},
false,
);
return true;
}
return true;
}
returnList = () => {
router.goBack();
};
returnList = () => {
router.goBack();
};
render() {
const { workId, init} = this.state;
if (!workId) {
return null;
}
const url = config.onestopPC.split("/#/");
const params = `id=${workId}&token=${getToken()}&init=${encodeURIComponent(JSON.stringify(init))}`;
let iframeUrl = `${url[0]}/#/IFrameForApply?${params}`;
console.log(iframeUrl);
// iframeUrl = `http://localhost:8001/onestop/IFrameForApply?${params}`;
return (
<PageHeaderWrapper title="">
<div style={{
visibility: "visible",
backgroundColor: "#fff",
paddingLeft: "24px"
}}>
<Shell>
<div style={{
height: "54px",
padding: "12px 0 12px 12px",
display: "block",
}}>
<ButtonDiy name="返回"
className="defaultBlue"
handleClick={this.returnList}
icon="arrow-left"
/>
</div>
</Shell>
<iframe src={iframeUrl}
frameBorder={0}
id="applyIframeId"
name="applyIframe"
marginWidth="0"
marginHeight="0"
allowtransparency="yes"
seamless
scrolling={"auto"}
style={{
width: "100%",
minHeight: "800px",
overflowY: "hidden",
backgroundColor: "#fff"
}}
/>
: null
</div>
</PageHeaderWrapper>
);
}
render() {
const { workId, init } = this.state;
if (!workId) {
return null;
}
const url = config.onestopPC.split('/#/');
const params = `id=${workId}&token=${getToken()}&init=${encodeURIComponent(
JSON.stringify(init),
)}`;
let iframeUrl = `${url[0]}/#/IFrameForApply?${params}`;
console.log(iframeUrl);
// iframeUrl = `http://localhost:8001/onestop/IFrameForApply?${params}`;
return (
<PageHeaderWrapper title="">
<div
style={{
visibility: 'visible',
backgroundColor: '#fff',
paddingLeft: '24px',
}}>
<Shell>
<div
style={{
height: '54px',
padding: '12px 0 12px 12px',
display: 'block',
}}>
<ButtonDiy
name="返回"
className="defaultBlue"
handleClick={this.returnList}
icon="arrow-left"
/>
</div>
</Shell>
<iframe
src={iframeUrl}
frameBorder={0}
id="applyIframeId"
name="applyIframe"
marginWidth="0"
marginHeight="0"
allowtransparency="yes"
seamless
scrolling={'auto'}
style={{
width: '100%',
minHeight: '800px',
overflowY: 'hidden',
backgroundColor: '#fff',
}}
/>
: null
</div>
</PageHeaderWrapper>
);
}
}
const pageSetting = {
type: 'list', // 页面类型 list列表 可能包含有其他类型的 比如 detail 详情 add 新增 update 更新 等等 ....
listConfig:{
selectRows: true, // 是否可以行选择,
paging: true, // 是否可以分页,
searchArea: false, // 是否拥有 搜索区dom,
buttonArea: true, // 是否拥有 按钮区,
}
type: 'list', // 页面类型 list列表 可能包含有其他类型的 比如 detail 详情 add 新增 update 更新 等等 ....
listConfig: {
selectRows: true, // 是否可以行选择,
paging: true, // 是否可以分页,
searchArea: false, // 是否拥有 搜索区dom,
buttonArea: true, // 是否拥有 按钮区,
},
};
export default pageSetting;
......@@ -8,132 +8,136 @@ import { ModalInfo } from '@/baseComponent/Modal';
import ButtonDiy from '@/baseComponent/ButtonDiy';
export default class AuditPage extends Component {
constructor(props) {
super(props);
this.state = {};
}
constructor(props) {
super(props);
this.state = {};
}
componentDidMount() {}
componentDidMount() {}
handleButtonSet = () => {
const { hasBatchAudit, batchAuditButtonName } = this.props;
return {
tab1: [
hasBatchAudit ? {
type: 'audit',
component: 'RenderComponent',
render: ({ selectRows, getPage }) => {
const disabled = !selectRows || !Array.isArray(selectRows) || !selectRows.length;
function handleClick(onShow) {
const taskName = selectRows[0].taskName;
const differentTask = selectRows.slice(1).find(i => i.taskName !== taskName);
if (differentTask) {
return ModalInfo((
<div>
<strong style={{color: "red"}}> {differentTask.taskName} </strong>
<strong> {taskName} </strong>不能一起审核。<br />
请将分开操作。
</div>
));
}
onShow();
}
return (
<AuditModal selectRows={selectRows} getPage={getPage}>
{({ onShow }) => (
<ButtonDiy
name={batchAuditButtonName || "批量审核"}
handleClick={() => handleClick(onShow)}
disabled={disabled}
/>
)}
</AuditModal>
);
},
}: false,
].filter(i => i),
tab2: [],
};
};
handleButtonSet = () => {
const { hasBatchAudit, batchAuditButtonName } = this.props;
return {
tab1: [
hasBatchAudit
? {
type: 'audit',
component: 'RenderComponent',
render: ({ selectRows, getPage }) => {
const disabled = !selectRows || !Array.isArray(selectRows) || !selectRows.length;
function handleClick(onShow) {
const taskName = selectRows[0].taskName;
const differentTask = selectRows.slice(1).find((i) => i.taskName !== taskName);
if (differentTask) {
return ModalInfo(
<div>
<strong style={{ color: 'red' }}> {differentTask.taskName} </strong>
<strong> {taskName} </strong>
不能一起审核。
<br />
请将分开操作。
</div>,
);
}
onShow();
}
return (
<AuditModal selectRows={selectRows} getPage={getPage}>
{({ onShow }) => (
<ButtonDiy
name={batchAuditButtonName || '批量审核'}
handleClick={() => handleClick(onShow)}
disabled={disabled}
/>
)}
</AuditModal>
);
},
}
: false,
].filter((i) => i),
tab2: [],
};
};
handleSearchSet = () => {
const { columns, searchCondition } = this.props;
console.log(searchCondition);
const tab1 = {
search: {
field: {},
getPageService: getWaitPage,
beforeSearchData: (data) => {
let searcherKeyValue = {};
for(let item of searchCondition){
if(typeof data[item.key] !== 'undefined'){
searcherKeyValue[item.base52] = data[item.key];
}
}
if(searcherKeyValue && Object.keys(searcherKeyValue).length){
data.searcherKeyValue = JSON.stringify(searcherKeyValue);
}
console.log(data);
return data;
},
responseCallBack: response => {
return response;
},
condition: searchCondition,
nameSpan: { big: 8, small: 9 },
fileSpan: { big: 4, small: 4 },
},
tableRowKey: 'id',
columns,
};
const tab2 = {
search: {
field: {},
getPageService: getHandledPage,
responseCallBack: response => {
return response;
},
beforeSearchData: (data) => {
let searcherKeyValue = {};
for(let item of searchCondition){
if(typeof data[item.key] !== 'undefined'){
searcherKeyValue[item.base52] = data[item.key];
}
}
if(searcherKeyValue && Object.keys(searcherKeyValue).length){
data.searcherKeyValue = JSON.stringify(searcherKeyValue);
}
console.log(data);
return data;
},
condition: searchCondition,
nameSpan: { big: 8, small: 9 },
fileSpan: { big: 4, small: 4 },
},
tableRowKey: 'id',
columns,
};
return {
tab1,
tab2,
};
};
handleSearchSet = () => {
const { columns, searchCondition } = this.props;
console.log(searchCondition);
const tab1 = {
search: {
field: {},
getPageService: getWaitPage,
beforeSearchData: (data) => {
let searcherKeyValue = {};
for (let item of searchCondition) {
if (typeof data[item.key] !== 'undefined') {
searcherKeyValue[item.base52] = data[item.key];
}
}
if (searcherKeyValue && Object.keys(searcherKeyValue).length) {
data.searcherKeyValue = JSON.stringify(searcherKeyValue);
}
console.log(data);
return data;
},
responseCallBack: (response) => {
return response;
},
condition: searchCondition,
nameSpan: { big: 8, small: 9 },
fileSpan: { big: 4, small: 4 },
},
tableRowKey: 'id',
columns,
};
const tab2 = {
search: {
field: {},
getPageService: getHandledPage,
responseCallBack: (response) => {
return response;
},
beforeSearchData: (data) => {
let searcherKeyValue = {};
for (let item of searchCondition) {
if (typeof data[item.key] !== 'undefined') {
searcherKeyValue[item.base52] = data[item.key];
}
}
if (searcherKeyValue && Object.keys(searcherKeyValue).length) {
data.searcherKeyValue = JSON.stringify(searcherKeyValue);
}
console.log(data);
return data;
},
condition: searchCondition,
nameSpan: { big: 8, small: 9 },
fileSpan: { big: 4, small: 4 },
},
tableRowKey: 'id',
columns,
};
return {
tab1,
tab2,
};
};
render() {
const { workId, dataBaseId, addFields, searchCondition } = this.props;
render() {
const { workId, dataBaseId, addFields, searchCondition } = this.props;
return (
<PageHeaderWrapper title="">
<ListTab
tabList={pageSetting.tabList}
pageButton={this.handleButtonSet({})}
workId={workId}
dataBaseId={dataBaseId}
searchCondition={searchCondition}
addFields={addFields}
pageSearch={this.handleSearchSet({})}
/>
</PageHeaderWrapper>
);
}
return (
<PageHeaderWrapper title="">
<ListTab
tabList={pageSetting.tabList}
pageButton={this.handleButtonSet({})}
workId={workId}
dataBaseId={dataBaseId}
searchCondition={searchCondition}
addFields={addFields}
pageSearch={this.handleSearchSet({})}
/>
</PageHeaderWrapper>
);
}
}
......@@ -4,19 +4,15 @@
* 钟是志
*
* */
import React, {Component} from 'react';
import React, { Component } from 'react';
import AuditPage from './index';
export default class BatchAudit extends Component{
constructor(props) {
super(props);
}
export default class BatchAudit extends Component {
constructor(props) {
super(props);
}
render() {
return(
<AuditPage {...this.props}
hasBatchAudit={true}
/>
)
}
render() {
return <AuditPage {...this.props} hasBatchAudit={true} />;
}
}
......@@ -8,64 +8,71 @@ import List from './List';
const TabPane = Tabs.TabPane;
export default class ListTab extends Component {
constructor(props) {
super(props);
const { tabList } = this.props;
const tabKeys = Object.keys(tabList);
this.state = {
activeKey: tabKeys[0],
tabKeys: tabKeys,
};
}
constructor(props) {
super(props);
const { tabList } = this.props;
const tabKeys = Object.keys(tabList);
this.state = {
activeKey: tabKeys[0],
tabKeys: tabKeys,
};
}
handleChangeTab = (activeKey) => {
handleChangeTab = (activeKey) => {
this.setState(
{
activeKey: '-111111',
},
() => {
setTimeout(() => {
this.setState({
activeKey: activeKey,
});
}, 30);
},
);
};
this.setState({
activeKey: '-111111',
},()=>{
setTimeout(()=>{
this.setState({
activeKey: activeKey,
})
} ,30);
});
};
render() {
const { tabList, pageSearch, pageButton, workId, dataBaseId, addFields, searchCondition } = this.props;
const { activeKey, tabKeys } = this.state;
return (
<Fragment>
<Shell styleShell={{marginTop: 0}}>
{/*<SearchDom />*/}
<Tabs activeKey={activeKey}
className={styles.ListTab}
onChange={this.handleChangeTab}>
{tabKeys.map((item) => {
return <TabPane tab={tabList[item].name} key={item}>
</TabPane>
})}
</Tabs>
</Shell>
{tabKeys.map((item) => {
return activeKey === item ?
<List listConfig={tabList[item].listConfig}
key={item}
workId={workId}
addFields={addFields}
searchCondition={searchCondition}
dataBaseId={dataBaseId}
pageSearch={pageSearch[item]}
pageButton={pageButton[item]}
/> : null;
})}
</Fragment>
);
}
render() {
const {
tabList,
pageSearch,
pageButton,
workId,
dataBaseId,
addFields,
searchCondition,
} = this.props;
const { activeKey, tabKeys } = this.state;
return (
<Fragment>
<Shell styleShell={{ marginTop: 0 }}>
{/*<SearchDom />*/}
<Tabs activeKey={activeKey} className={styles.ListTab} onChange={this.handleChangeTab}>
{tabKeys.map((item) => {
return <TabPane tab={tabList[item].name} key={item} />;
})}
</Tabs>
</Shell>
{tabKeys.map((item) => {
return activeKey === item ? (
<List
listConfig={tabList[item].listConfig}
key={item}
workId={workId}
addFields={addFields}
searchCondition={searchCondition}
dataBaseId={dataBaseId}
pageSearch={pageSearch[item]}
pageButton={pageButton[item]}
/>
) : null;
})}
</Fragment>
);
}
}
ListTab.propTypes = {};
ListTab.defaultProps = {};
......@@ -5,147 +5,162 @@
*
* */
import React, { } from 'react';
import React from 'react';
import * as service from '../publicApiService';
import AuditPage from './AuditPage';
import * as destructionFunc from '../destruction';
import { Link } from 'dva/router';
export default class Index extends React.Component {
static defaultProps = {
hasBatchAudit: false, // 是否有批量审核按钮 默认关掉 如果有需要再在外面包一层 2020年5月6日 18:44:11 钟是志
batchAuditButtonName: '批量审核', // 如果需要批量审核 则直接用 BatchAudit.js 文件
};
static defaultProps = {
hasBatchAudit: false, // 是否有批量审核按钮 默认关掉 如果有需要再在外面包一层 2020年5月6日 18:44:11 钟是志
batchAuditButtonName: '批量审核', // 如果需要批量审核 则直接用 BatchAudit.js 文件
};
constructor(props) {
super(props);
constructor(props) {
super(props);
let pathname = this.props.location.pathname;
this.state = {
columns: [],
dataList: [],
headerInfo: [],
workId: this.props.workId || '',
searchCondition: [],
pathname,
dataBaseId: this.props.dataBaseId || '',
addCondition: [],
addFields: [], // 新增时填写的字段。
tableInfo: {}, // 表格配置属性
allConfigSetInfo: {}, // getFormDetail 返回的数据
};
}
let pathname = this.props.location.pathname;
this.state = {
columns: [],
dataList: [],
headerInfo: [],
workId: this.props.workId || '',
searchCondition: [],
pathname,
dataBaseId: this.props.dataBaseId || '',
addCondition: [],
addFields: [], // 新增时填写的字段。
tableInfo: {}, // 表格配置属性
allConfigSetInfo: {}, // getFormDetail 返回的数据
};
};
getFormDetail = (workId) => {
const { dataBaseId } = this.state;
service.getFormDetail(workId).then((response) => {
if (typeof response.unifiedServicePatternModel === 'undefined') {
return false;
}
destructionFunc.destructionGetDetail(response).then((x) => {
const { addFields, tableInfo, allConfigSetInfo, searchCondition } = x;
this.setState(
{
addFields,
tableInfo,
searchCondition,
allConfigSetInfo,
},
() => {
this.giveDetailColumns();
},
);
});
});
};
getFormDetail = (workId) => {
const { dataBaseId } = this.state;
service.getFormDetail(workId).then((response) => {
if (typeof response.unifiedServicePatternModel === 'undefined') {
return false;
}
destructionFunc.destructionGetDetail(response).then((x) => {
const { addFields, tableInfo, allConfigSetInfo, searchCondition } = x;
this.setState({
addFields,
tableInfo,
searchCondition,
allConfigSetInfo,
},() => {
this.giveDetailColumns();
});
});
});
};
giveDetailColumns = () => {
const { columns, workId, dataBaseId, addFields, tableInfo } = this.state;
const process_status = columns.find((x) => {
return x.name === 'process_status';
});
if (process_status && process_status.dataIndex) {
process_status.render = (text, record) => {
return record.statusName || record[process_status.dataIndex];
};
}
columns.push({
dataIndex: 'operation',
title: '操作',
fixed: columns.length > 12 ? 'right' : false,
render: (text, record) => {
return (
<Link
to={{
pathname: './Detail',
state: {
workId,
dataBaseId,
record,
addFields,
tableInfo,
},
}}>
详情
</Link>
);
},
});
this.setState({
columns,
});
};
giveDetailColumns = () =>{
const { columns, workId, dataBaseId, addFields, tableInfo } = this.state;
const process_status = columns.find((x) => {
return x.name === 'process_status';
});
if(process_status && process_status.dataIndex){
process_status.render = (text ,record)=> {
return record.statusName || record[process_status.dataIndex];
};
}
columns.push(
{
dataIndex: 'operation',
title: '操作',
fixed: columns.length > 12 ? 'right' : false,
render: (text, record) => {
return ( <Link to={
{
pathname: "./Detail",
state: {
workId,
dataBaseId,
record,
addFields,
tableInfo
},
}}>
详情
</Link> );
},
},
);
this.setState({
columns,
})
};
getColumn = () => {
const { workId } = this.state;
service.getColumns(workId).then((response) => {
response = response.filter((x) => {
return x.title !== '流程进度';
});
if (response && response.length) {
this.setState(
{
columns: response, // 表头
},
() => {
this.getFormDetail(workId);
},
);
}
});
};
getColumn = () => {
const { workId } = this.state;
service.getColumns(workId).then((response) => {
response = response.filter((x) => {
return x.title !== '流程进度';
});
if (response && response.length) {
this.setState({
columns: response, // 表头
},()=>{
this.getFormDetail(workId);
});
}
});
};
componentDidMount() {
const { pathname } = this.state;
const { workId } = this.state;
if (workId) {
this.getColumn();
} else {
service.getId(pathname).then((x) => {
this.setState(
{
workId: x.workId,
dataBaseId: x.dataBaseId,
},
() => {
this.getColumn();
},
);
});
}
}
componentDidMount() {
const { pathname } = this.state;
const { workId } = this.state;
if(workId){
this.getColumn();
}else{
service.getId(pathname).then((x)=>{
this.setState({
workId: x.workId,
dataBaseId: x.dataBaseId,
},()=>{
this.getColumn();
})
});
}
}
render() {
const { workId, dataBaseId, columns, searchCondition, addFields, allConfigSetInfo, tableInfo } = this.state;
const { hasBatchAudit, batchAuditButtonName } = this.props;
if(!workId){
return null;
}
return (
<AuditPage
hasBatchAudit={hasBatchAudit}
workId={workId}
dataBaseId={dataBaseId}
columns={columns}
addFields={addFields}
tableInfo={tableInfo}
allConfigSetInfo={allConfigSetInfo}
searchCondition={searchCondition}
batchAuditButtonName={batchAuditButtonName}
/>
);
}
render() {
const {
workId,
dataBaseId,
columns,
searchCondition,
addFields,
allConfigSetInfo,
tableInfo,
} = this.state;
const { hasBatchAudit, batchAuditButtonName } = this.props;
if (!workId) {
return null;
}
return (
<AuditPage
hasBatchAudit={hasBatchAudit}
workId={workId}
dataBaseId={dataBaseId}
columns={columns}
addFields={addFields}
tableInfo={tableInfo}
allConfigSetInfo={allConfigSetInfo}
searchCondition={searchCondition}
batchAuditButtonName={batchAuditButtonName}
/>
);
}
}
const pageSetting = {
type: 'listTab', // 页面类型
tabList: {
tab1:{
name:'待处理',
listConfig:{
selectRows: true, // 是否可以行选择,
paging: true, // 是否可以分页,
searchArea: true, // 是否拥有 搜索区dom,
buttonArea: true, // 是否拥有 按钮区,
}
},
tab2:{
name:'已处理',
listConfig:{
selectRows: true, // 是否可以行选择,
paging: true, // 是否可以分页,
searchArea: true, // 是否拥有 搜索区dom,
buttonArea: true, // 是否拥有 按钮区,
},
},
},
type: 'listTab', // 页面类型
tabList: {
tab1: {
name: '待处理',
listConfig: {
selectRows: true, // 是否可以行选择,
paging: true, // 是否可以分页,
searchArea: true, // 是否拥有 搜索区dom,
buttonArea: true, // 是否拥有 按钮区,
},
},
tab2: {
name: '已处理',
listConfig: {
selectRows: true, // 是否可以行选择,
paging: true, // 是否可以分页,
searchArea: true, // 是否拥有 搜索区dom,
buttonArea: true, // 是否拥有 按钮区,
},
},
},
};
export default pageSetting;
......@@ -4,7 +4,6 @@
* 用于 批量弹窗操作
* */
import ButtonDiy from '@/baseComponent/ButtonDiy';
import ModalDiy from '@/baseComponent/ModalDiy';
import FormArray from '../component/FormArray';
......@@ -14,190 +13,194 @@ import { message } from 'antd';
import PropTypes from 'prop-types';
export default class ModalBatch extends Component {
constructor(props) {
super(props);
const { values } = this.props;
this.state = {
showModal: false,
formValues: { ...values }, // 将默认值传进去 用于新增时可能遇到的需要传值的情况
};
}
componentWillUnmount() {
}
changeShow = () => {
const { beforeShowModel, selectRows, initFormValues } = this.props;
const { formValues, showModal } = this.state;
if (!selectRows.length && !this.state.showModal) {
message.warning('请至少选择一条数据');
return false;
}
if(initFormValues && !showModal){
initFormValues(selectRows,formValues).then((response)=>{
this.setState({
formValues: response ,
},()=>{
//console.log(this.state.formValues);
})
});
}
/**
* 设置modal是否显示
* */
let flag;
if (!showModal && beforeShowModel) {
beforeShowModel(this.props, ({ text, type, isNotShow }) => {
flag = isNotShow;
if (isNotShow && text) {
message[type](text);
}
});
}
if (flag) {
return false;
}
/**
* 设置modal是否显示
* */
this.clearData();
this.setState({
showModal: !showModal,
});
};
formStateChange = (value, key) => {
let oldValue = this.state.formValues;
oldValue[key] = value;
this.setState({
formValues: oldValue,
});
};
clearData = () => {
const { values, giveDefaultValue, selectRows} = this.props;
let formValues = {
...values,
};
if(giveDefaultValue){
formValues = giveDefaultValue(selectRows,formValues);
}
this.setState({
formValues,
});
};
handleOk = () => {
let { formValues } = this.state;
let param = { ...formValues };
const { fields, url, responseCallBack, getPage,
beforeSubmit, selectRows, postKey, sourceKey,
handleSelectRows, apiServiceApi } = this.props;
for (let item of fields) {
if (item.required && !formValues[item.key] && formValues[item.key] !== 0) {
message.warning(`${item.name}是必填项,请填写`);
return false;
}
/**
* 校验开始时间必须在结束时间之前
* */
if (item.rule && item.rule === 'mustAfterStart') {
const check = checkDate(formValues[item.key], formValues[item.checkKey]);
if (!check) {
message.warning(`${item.name}必须在${item.checkKeyName}之后`);
return false;
}
}
}
param[postKey] = selectRows.map((item) => {
return item[sourceKey];
});
if (beforeSubmit) {
let postData = beforeSubmit(this.props, formValues);
param = {
...param,
...postData,
};
}
apiServiceApi(param).then((response) => {
if (response) {
if (responseCallBack && !responseCallBack(response)) {
this.changeShow();
return false;
} else {
handleSelectRows([]);
message.success('保存成功');
this.changeShow();
getPage();
}
} else {
this.changeShow();
return false;
}
});
};
render() {
const { showModal, formValues } = this.state;
const { name, className, fields, nameSpan, fileSpan } = this.props;
return (
<Fragment>
<ButtonDiy name={name}
className={className}
handleClick={this.changeShow}/>
{showModal ?
<ModalDiy handleOk={this.handleOk}
title={name}
handleCancel={this.changeShow}
>
<FormArray config={fields}
value={formValues}
changeValue={this.formStateChange}
nameSpan={nameSpan}
fileSpan={fileSpan}
style={{ paddingTop: '0px' }}
/>
</ModalDiy> : null}
</Fragment>);
}
constructor(props) {
super(props);
const { values } = this.props;
this.state = {
showModal: false,
formValues: { ...values }, // 将默认值传进去 用于新增时可能遇到的需要传值的情况
};
}
componentWillUnmount() {}
changeShow = () => {
const { beforeShowModel, selectRows, initFormValues } = this.props;
const { formValues, showModal } = this.state;
if (!selectRows.length && !this.state.showModal) {
message.warning('请至少选择一条数据');
return false;
}
if (initFormValues && !showModal) {
initFormValues(selectRows, formValues).then((response) => {
this.setState(
{
formValues: response,
},
() => {
//console.log(this.state.formValues);
},
);
});
}
/**
* 设置modal是否显示
* */
let flag;
if (!showModal && beforeShowModel) {
beforeShowModel(this.props, ({ text, type, isNotShow }) => {
flag = isNotShow;
if (isNotShow && text) {
message[type](text);
}
});
}
if (flag) {
return false;
}
/**
* 设置modal是否显示
* */
this.clearData();
this.setState({
showModal: !showModal,
});
};
formStateChange = (value, key) => {
let oldValue = this.state.formValues;
oldValue[key] = value;
this.setState({
formValues: oldValue,
});
};
clearData = () => {
const { values, giveDefaultValue, selectRows } = this.props;
let formValues = {
...values,
};
if (giveDefaultValue) {
formValues = giveDefaultValue(selectRows, formValues);
}
this.setState({
formValues,
});
};
handleOk = () => {
let { formValues } = this.state;
let param = { ...formValues };
const {
fields,
url,
responseCallBack,
getPage,
beforeSubmit,
selectRows,
postKey,
sourceKey,
handleSelectRows,
apiServiceApi,
} = this.props;
for (let item of fields) {
if (item.required && !formValues[item.key] && formValues[item.key] !== 0) {
message.warning(`${item.name}是必填项,请填写`);
return false;
}
/**
* 校验开始时间必须在结束时间之前
* */
if (item.rule && item.rule === 'mustAfterStart') {
const check = checkDate(formValues[item.key], formValues[item.checkKey]);
if (!check) {
message.warning(`${item.name}必须在${item.checkKeyName}之后`);
return false;
}
}
}
param[postKey] = selectRows.map((item) => {
return item[sourceKey];
});
if (beforeSubmit) {
let postData = beforeSubmit(this.props, formValues);
param = {
...param,
...postData,
};
}
apiServiceApi(param).then((response) => {
if (response) {
if (responseCallBack && !responseCallBack(response)) {
this.changeShow();
return false;
} else {
handleSelectRows([]);
message.success('保存成功');
this.changeShow();
getPage();
}
} else {
this.changeShow();
return false;
}
});
};
render() {
const { showModal, formValues } = this.state;
const { name, className, fields, nameSpan, fileSpan } = this.props;
return (
<Fragment>
<ButtonDiy name={name} className={className} handleClick={this.changeShow} />
{showModal ? (
<ModalDiy handleOk={this.handleOk} title={name} handleCancel={this.changeShow}>
<FormArray
config={fields}
value={formValues}
changeValue={this.formStateChange}
nameSpan={nameSpan}
fileSpan={fileSpan}
style={{ paddingTop: '0px' }}
/>
</ModalDiy>
) : null}
</Fragment>
);
}
}
ModalBatch.propTypes = {
name: PropTypes.string, // 按钮名称和 弹窗的标题
className: PropTypes.string, // 按钮样式
fields: PropTypes.array.isRequired, // 填写的字段的配置
values: PropTypes.object, // 如果有默认参数 则在页面的业务逻辑中传进来
url: PropTypes.string.isRequired, // 接口url
responseCallBack: PropTypes.func, // 接口返回数据检查
getPage: PropTypes.func, // 刷新页面的方法
nameSpan: PropTypes.object, // 页面排版
fileSpan: PropTypes.object, // 页面排版
name: PropTypes.string, // 按钮名称和 弹窗的标题
className: PropTypes.string, // 按钮样式
fields: PropTypes.array.isRequired, // 填写的字段的配置
values: PropTypes.object, // 如果有默认参数 则在页面的业务逻辑中传进来
url: PropTypes.string.isRequired, // 接口url
responseCallBack: PropTypes.func, // 接口返回数据检查
getPage: PropTypes.func, // 刷新页面的方法
nameSpan: PropTypes.object, // 页面排版
fileSpan: PropTypes.object, // 页面排版
};
ModalBatch.defaultProps = {
name: '新增',
className: 'primaryBlue',
values: {},
sourceKey: 'id',
postKey: 'ids',
selectRows: [],
url: 'asdasd/asdasd',
responseCallBack: (response) => {
return !!response;
},
/*beforeShowModel: (props, callback) => {
name: '新增',
className: 'primaryBlue',
values: {},
sourceKey: 'id',
postKey: 'ids',
selectRows: [],
url: 'asdasd/asdasd',
responseCallBack: (response) => {
return !!response;
},
/*beforeShowModel: (props, callback) => {
},*/
nameSpan: { big: 4, small: 4 },
fileSpan: { big: 1, small: 1 },
nameSpan: { big: 4, small: 4 },
fileSpan: { big: 1, small: 1 },
};
......@@ -7,101 +7,113 @@
* */
import ButtonDiy from '@/baseComponent/ButtonDiy';
import React, { Component, Fragment } from 'react';
import { message, Modal } from 'antd';
import { message, Modal } from 'antd';
import PropTypes from 'prop-types';
import * as service from '@/highOrderComponent/Service';
export default class ModalConfirm extends Component {
handleConfirm = () => {
const {
selectRows,
name,
contentSentence,
onlyOne,
checkSelectRow,
noNeedCheckSelect,
listData,
} = this.props;
if (typeof noNeedCheckSelect === 'undefined' && !selectRows.length) {
message.warning('请至少选择一条数据');
return false;
}
handleConfirm = () => {
const { selectRows,name, contentSentence, onlyOne, checkSelectRow, noNeedCheckSelect,listData } = this.props;
if(typeof noNeedCheckSelect === 'undefined' && !selectRows.length){
message.warning('请至少选择一条数据');
return false;
}
if(onlyOne && selectRows.length > 1){
message.warning('只能选择一条数据进行操作');
return false;
}
if(checkSelectRow){
let res = checkSelectRow(selectRows, listData);
if(res && res.result === false){
message.warning(res.info);
return false;
}
}
Modal.confirm({
title: name,
content: contentSentence,
onOk: this.handleOk,
okText: '确定',
cancelText: '取消',
});
};
if (onlyOne && selectRows.length > 1) {
message.warning('只能选择一条数据进行操作');
return false;
}
if (checkSelectRow) {
let res = checkSelectRow(selectRows, listData);
if (res && res.result === false) {
message.warning(res.info);
return false;
}
}
Modal.confirm({
title: name,
content: contentSentence,
onOk: this.handleOk,
okText: '确定',
cancelText: '取消',
});
};
handleOk = () => {
const { selectRows, postKey, sourceKey, url,
responseCallBack, getPage,fields,formValues,
beforeUpdate,search } = this.props;
let data = {};
if(fields){
data = {...fields};
}
data[postKey] = selectRows.map( (item) => {
return item[sourceKey];
});
data[postKey] = data[postKey].join(',');
if(beforeUpdate){
data = beforeUpdate(data,selectRows,formValues,search);
}
service.addOrUpdate(data,url).then((response) => {
if(responseCallBack && !responseCallBack(response)){
return false;
}
if(!response){
return false;
}else{
message.success('操作成功');
getPage();
}
});
};
handleOk = () => {
const {
selectRows,
postKey,
sourceKey,
url,
responseCallBack,
getPage,
fields,
formValues,
beforeUpdate,
search,
} = this.props;
let data = {};
if (fields) {
data = { ...fields };
}
data[postKey] = selectRows.map((item) => {
return item[sourceKey];
});
data[postKey] = data[postKey].join(',');
if (beforeUpdate) {
data = beforeUpdate(data, selectRows, formValues, search);
}
service.addOrUpdate(data, url).then((response) => {
if (responseCallBack && !responseCallBack(response)) {
return false;
}
if (!response) {
return false;
} else {
message.success('操作成功');
getPage();
}
});
};
render() {
const { name, className } = this.props;
return (
<Fragment>
<ButtonDiy name={name}
className={className}
handleClick={this.handleConfirm}/>
</Fragment>);
}
render() {
const { name, className } = this.props;
return (
<Fragment>
<ButtonDiy name={name} className={className} handleClick={this.handleConfirm} />
</Fragment>
);
}
}
ModalConfirm.propTypes = {
name: PropTypes.string, // 按钮名称和 弹窗的标题
selectRows: PropTypes.array.isRequired, // 选择的数据.数组类型
className: PropTypes.string, // 按钮样式
sourceKey: PropTypes.string.isRequired, // 通过什么字段删除
postKey: PropTypes.string, // 提交的字段名.
url: PropTypes.string.isRequired, // 接口url
responseCallBack: PropTypes.func, // 接口返回数据检查
getPage: PropTypes.func.isRequired, // 刷新页面的方法
name: PropTypes.string, // 按钮名称和 弹窗的标题
selectRows: PropTypes.array.isRequired, // 选择的数据.数组类型
className: PropTypes.string, // 按钮样式
sourceKey: PropTypes.string.isRequired, // 通过什么字段删除
postKey: PropTypes.string, // 提交的字段名.
url: PropTypes.string.isRequired, // 接口url
responseCallBack: PropTypes.func, // 接口返回数据检查
getPage: PropTypes.func.isRequired, // 刷新页面的方法
};
ModalConfirm.defaultProps = {
name: '一键审核通过',
className: 'defaultBlue',
url: 'asdasd/asdasd',
contentSentence: '您确认xxxxx吗?',
sourceKey: 'id',
postKey: 'ids',
selectRows: [],
responseCallBack: (response)=>{
return !!response;
},
name: '一键审核通过',
className: 'defaultBlue',
url: 'asdasd/asdasd',
contentSentence: '您确认xxxxx吗?',
sourceKey: 'id',
postKey: 'ids',
selectRows: [],
responseCallBack: (response) => {
return !!response;
},
};
......@@ -7,94 +7,89 @@
* */
import ButtonDiy from '@/baseComponent/ButtonDiy';
import React, { Component, Fragment } from 'react';
import { message, Modal } from 'antd';
import { message, Modal } from 'antd';
import PropTypes from 'prop-types';
import * as service from '@/highOrderComponent/Service';
export default class ModalDelete extends Component {
handleDelete = () => {
const { selectRows, checkBeforeDelete, cannotDeleteSentence, deleteSentence } = this.props;
if (!selectRows.length) {
message.warning('请选择你要删除的数据');
return false;
}
handleDelete = () => {
const { selectRows, checkBeforeDelete, cannotDeleteSentence, deleteSentence} = this.props;
if(!selectRows.length){
message.warning('请选择你要删除的数据');
return false;
}
if (checkBeforeDelete) {
const check = checkBeforeDelete(selectRows);
if (!check) {
if (cannotDeleteSentence) {
message.warning(cannotDeleteSentence);
return false;
} else {
message.warning('数据关联,不能删除');
return false;
}
}
}
if(checkBeforeDelete){
const check = checkBeforeDelete(selectRows);
if(!check){
if(cannotDeleteSentence){
message.warning(cannotDeleteSentence);
return false;
}else{
message.warning('数据关联,不能删除');
return false;
}
}
}
Modal.confirm({
title: '删除',
content: deleteSentence || `你确定要删除吗?`,
onOk: this.handleOk,
okText: '确认',
cancelText: '取消',
});
};
handleOk = () => {
const { selectRows, postKey, sourceKey, url, responseCallBack, getPage } = this.props;
const data = {};
data[postKey] = selectRows.map((item) => {
return item[sourceKey];
});
data[postKey] = data[postKey].join(',');
service.deleteData(data, url).then((response) => {
if (!response) {
getPage();
}
if (responseCallBack && !responseCallBack(response)) {
return false;
} else {
message.success('删除成功');
getPage();
}
});
};
Modal.confirm({
title: '删除',
content: deleteSentence || `你确定要删除吗?`,
onOk: this.handleOk,
okText: '确认',
cancelText: '取消',
});
};
handleOk = () => {
const { selectRows, postKey, sourceKey, url, responseCallBack, getPage } = this.props;
const data = {};
data[postKey] = selectRows.map( (item) => {
return item[sourceKey];
});
data[postKey] = data[postKey].join(',');
service.deleteData(data,url).then((response) => {
if(!response){
getPage();
}
if(responseCallBack && !responseCallBack(response)){
return false;
}else{
message.success('删除成功');
getPage();
}
});
};
render() {
const { name, className } = this.props;
return (
<Fragment>
<ButtonDiy name={name}
className={className}
handleClick={this.handleDelete}/>
</Fragment>);
}
render() {
const { name, className } = this.props;
return (
<Fragment>
<ButtonDiy name={name} className={className} handleClick={this.handleDelete} />
</Fragment>
);
}
}
ModalDelete.propTypes = {
name: PropTypes.string, // 按钮名称和 弹窗的标题
selectRows: PropTypes.array.isRequired, // 选择的数据.
className: PropTypes.string, // 按钮样式
sourceKey: PropTypes.string.isRequired, // 通过什么字段删除
postKey: PropTypes.string, // 提交的字段名. ids
url: PropTypes.string.isRequired, // 接口url
responseCallBack: PropTypes.func, // 接口返回数据检查
getPage: PropTypes.func, // 刷新页面的方法
checkBeforeDelete: PropTypes.func, // 在删除前对数据进行检查 如果返回false 则不能删除数据
name: PropTypes.string, // 按钮名称和 弹窗的标题
selectRows: PropTypes.array.isRequired, // 选择的数据.
className: PropTypes.string, // 按钮样式
sourceKey: PropTypes.string.isRequired, // 通过什么字段删除
postKey: PropTypes.string, // 提交的字段名. ids
url: PropTypes.string.isRequired, // 接口url
responseCallBack: PropTypes.func, // 接口返回数据检查
getPage: PropTypes.func, // 刷新页面的方法
checkBeforeDelete: PropTypes.func, // 在删除前对数据进行检查 如果返回false 则不能删除数据
};
ModalDelete.defaultProps = {
name: '删除',
className: 'defaultRed',
url: 'asdasd/asdasd',
deleteKey: 'id',
postKey: 'ids',
selectRows: [],
responseCallBack: (response)=>{
return !!response;
},
name: '删除',
className: 'defaultRed',
url: 'asdasd/asdasd',
deleteKey: 'id',
postKey: 'ids',
selectRows: [],
responseCallBack: (response) => {
return !!response;
},
};
......@@ -6,11 +6,10 @@
* 弹窗中包含一个表单 并填写数据后点确定 调接口->关闭弹窗 刷新页面
* */
import ButtonDiy from '@/baseComponent/ButtonDiy';
import ModalDiy from '@/baseComponent/ModalDiy';
import React, { Component, Fragment } from 'react';
import { deepCopy, } from '@/baseComponent/utils';
import { deepCopy } from '@/baseComponent/utils';
import { mustHaveValue, transLateTimeTOUnix } from '../../config/index';
import { message } from 'antd';
import PropTypes from 'prop-types';
......@@ -18,145 +17,149 @@ import { startProcess } from '../publicApiService';
import FormArray from '../component/FormArray';
export default class ModalForm extends Component {
constructor(props) {
super(props);
const { values } = this.props;
this.state={
showModal: false,
formValues: { ...values }, // 将默认值传进去 用于新增时可能遇到的需要传值的情况
requireOtherFiled:{}
};
}
componentWillUnmount(){
}
changeShow = () => {
const { showModal } = this.state;
this.clearData();
this.setState({
showModal: !showModal,
});
};
formStateChange = (value, key) => {
const {diyFormStateChange} = this.props;
if(diyFormStateChange){
return diyFormStateChange(value, key, this);
}
let oldValue = this.state.formValues;
if(typeof value === 'object'){
oldValue[key] = deepCopy(value);
}else{
oldValue[key] = value;
}
this.setState({
formValues: oldValue,
});
};
clearData = () => {
const { values } = this.props;
this.setState({
formValues: {...values},
});
};
handleOk = () => {
let { formValues} = this.state;
const { fields, url, responseCallBack, getPage, beforeSubmit, workId, seriousOptions } = this.props;
if(!mustHaveValue(fields,formValues)){
return false;
}
let data = {
...formValues,
};
for(let item of fields){
if(data[item.key]){
data[item.key] = transLateTimeTOUnix(data[item.key], item.dataType);
}
if(data[item.endKey]){
data[item.endKey] = transLateTimeTOUnix(data[item.endKey], item.dataType);
}
}
if(beforeSubmit){
data = beforeSubmit(data,this);
if(!data){
return false;
}
}
const postData = {
content: JSON.stringify(data),
appId: workId,
};
if(seriousOptions && seriousOptions.length){
postData.level = seriousOptions[0].key;
}
startProcess(postData).then((response) => {
if(!responseCallBack(response)){
this.changeShow();
return false;
}else{
message.success('保存成功');
getPage();
this.changeShow();
}
})
};
render() {
const { showModal, formValues } = this.state;
const { name, className, fields, nameSpan, fileSpan, icon ,modalWidth} = this.props;
return (
<Fragment>
<ButtonDiy name={name}
className={className}
icon={icon}
handleClick={this.changeShow}/>
{showModal ?
<ModalDiy handleOk={this.handleOk}
title={name}
handleCancel={this.changeShow}
width={modalWidth}
>
<FormArray config={fields}
value={formValues}
changeValue={this.formStateChange}
nameSpan={nameSpan}
fileSpan={fileSpan}/>
</ModalDiy> : null}
</Fragment>);
}
constructor(props) {
super(props);
const { values } = this.props;
this.state = {
showModal: false,
formValues: { ...values }, // 将默认值传进去 用于新增时可能遇到的需要传值的情况
requireOtherFiled: {},
};
}
componentWillUnmount() {}
changeShow = () => {
const { showModal } = this.state;
this.clearData();
this.setState({
showModal: !showModal,
});
};
formStateChange = (value, key) => {
const { diyFormStateChange } = this.props;
if (diyFormStateChange) {
return diyFormStateChange(value, key, this);
}
let oldValue = this.state.formValues;
if (typeof value === 'object') {
oldValue[key] = deepCopy(value);
} else {
oldValue[key] = value;
}
this.setState({
formValues: oldValue,
});
};
clearData = () => {
const { values } = this.props;
this.setState({
formValues: { ...values },
});
};
handleOk = () => {
let { formValues } = this.state;
const {
fields,
url,
responseCallBack,
getPage,
beforeSubmit,
workId,
seriousOptions,
} = this.props;
if (!mustHaveValue(fields, formValues)) {
return false;
}
let data = {
...formValues,
};
for (let item of fields) {
if (data[item.key]) {
data[item.key] = transLateTimeTOUnix(data[item.key], item.dataType);
}
if (data[item.endKey]) {
data[item.endKey] = transLateTimeTOUnix(data[item.endKey], item.dataType);
}
}
if (beforeSubmit) {
data = beforeSubmit(data, this);
if (!data) {
return false;
}
}
const postData = {
content: JSON.stringify(data),
appId: workId,
};
if (seriousOptions && seriousOptions.length) {
postData.level = seriousOptions[0].key;
}
startProcess(postData).then((response) => {
if (!responseCallBack(response)) {
this.changeShow();
return false;
} else {
message.success('保存成功');
getPage();
this.changeShow();
}
});
};
render() {
const { showModal, formValues } = this.state;
const { name, className, fields, nameSpan, fileSpan, icon, modalWidth } = this.props;
return (
<Fragment>
<ButtonDiy name={name} className={className} icon={icon} handleClick={this.changeShow} />
{showModal ? (
<ModalDiy
handleOk={this.handleOk}
title={name}
handleCancel={this.changeShow}
width={modalWidth}>
<FormArray
config={fields}
value={formValues}
changeValue={this.formStateChange}
nameSpan={nameSpan}
fileSpan={fileSpan}
/>
</ModalDiy>
) : null}
</Fragment>
);
}
}
ModalForm.propTypes = {
name: PropTypes.string, // 按钮名称和 弹窗的标题
className: PropTypes.string, // 按钮样式
fields: PropTypes.array.isRequired, // 填写的字段的配置
values: PropTypes.object, // 如果有默认参数 则在页面的业务逻辑中传进来
url: PropTypes.string.isRequired, // 接口url
icon: PropTypes.string, // 按钮图标
responseCallBack: PropTypes.func, // 接口返回数据检查
getPage: PropTypes.func, // 刷新页面的方法
nameSpan: PropTypes.object, // 页面排版
fileSpan: PropTypes.object, // 页面排版
name: PropTypes.string, // 按钮名称和 弹窗的标题
className: PropTypes.string, // 按钮样式
fields: PropTypes.array.isRequired, // 填写的字段的配置
values: PropTypes.object, // 如果有默认参数 则在页面的业务逻辑中传进来
url: PropTypes.string.isRequired, // 接口url
icon: PropTypes.string, // 按钮图标
responseCallBack: PropTypes.func, // 接口返回数据检查
getPage: PropTypes.func, // 刷新页面的方法
nameSpan: PropTypes.object, // 页面排版
fileSpan: PropTypes.object, // 页面排版
};
ModalForm.defaultProps = {
name: '新增',
className: 'primaryBlue',
values: {},
url: 'asdasd/asdasd',
responseCallBack: (response)=>{
return !!response;
},
getPage: () => {
},
nameSpan: {big: 5, small: 5 },
fileSpan: {big: 1, small: 1 },
name: '新增',
className: 'primaryBlue',
values: {},
url: 'asdasd/asdasd',
responseCallBack: (response) => {
return !!response;
},
getPage: () => {},
nameSpan: { big: 5, small: 5 },
fileSpan: { big: 1, small: 1 },
};
......@@ -3,56 +3,56 @@ import React, { Component, Fragment } from 'react';
import ModalBatch from './ModalBatch';
import ModalForm from './ModalForm';
export default class ButtonListDom extends Component {
render() {
const { config, getPage, selectRows, formValues, children, search,listData } = this.props;
return (<div style={{ height: '50px', padding: '12px 0 12px 12px', positon:'relative'}}>
{config.map((item, i) => {
switch (item.component) {
case 'ModalForm': // 新增按钮 + 弹窗
return <ModalForm {...item}
key={item.type}
getPage={getPage}
selectRows={selectRows}
/>;
case 'ModalBatch': // 一般按钮 点击后弹出 填写一些类似 审核理由 意见之类的信息
return <ModalBatch key={item.type}
{...item}
handleSelectRows={this.props.handleSelectRows}
getPage={getPage}
selectRows={selectRows}/>;
case 'OpenUrl': // 点击按钮 打开一个新窗口
return window.open(item.url);
case "Normal":
return(
<ButtonDiy name={item.name}
key={item.type}
className={item.className || 'defaultBule'}
handleClick={() => {item.handleClick(selectRows, formValues, getPage,search)}}
/>
);
case 'RenderComponent':
return item.render({
name: item.name,
selectRows,
formValues,
getPage,
search,
listData
});
default:
break;
// return <ButtonDiy></ButtonDiy>;
}
})}
<span style={{display:'inline-block'}}>{children}</span>
</div>);
}
render() {
const { config, getPage, selectRows, formValues, children, search, listData } = this.props;
return (
<div style={{ height: '50px', padding: '12px 0 12px 12px', positon: 'relative' }}>
{config.map((item, i) => {
switch (item.component) {
case 'ModalForm': // 新增按钮 + 弹窗
return (
<ModalForm {...item} key={item.type} getPage={getPage} selectRows={selectRows} />
);
case 'ModalBatch': // 一般按钮 点击后弹出 填写一些类似 审核理由 意见之类的信息
return (
<ModalBatch
key={item.type}
{...item}
handleSelectRows={this.props.handleSelectRows}
getPage={getPage}
selectRows={selectRows}
/>
);
case 'OpenUrl': // 点击按钮 打开一个新窗口
return window.open(item.url);
case 'Normal':
return (
<ButtonDiy
name={item.name}
key={item.type}
className={item.className || 'defaultBule'}
handleClick={() => {
item.handleClick(selectRows, formValues, getPage, search);
}}
/>
);
case 'RenderComponent':
return item.render({
name: item.name,
selectRows,
formValues,
getPage,
search,
listData,
});
default:
break;
// return <ButtonDiy></ButtonDiy>;
}
})}
<span style={{ display: 'inline-block' }}>{children}</span>
</div>
);
}
}
......@@ -7,19 +7,19 @@ import { getToken } from '@/utils/authority';
import config from '@/config/config';
const getUrlInfo = (param) => {
let url = window.document.location.href.toString();
let u = url.split("?");
if (typeof(u[1]) == "string") {
u = u[1].split("&");
let get = {};
for (let i in u) {
let j = u[i].split("=");
get[j[0]] = decodeURIComponent(j[1]);
}
return get;
} else {
return {};
}
let url = window.document.location.href.toString();
let u = url.split('?');
if (typeof u[1] == 'string') {
u = u[1].split('&');
let get = {};
for (let i in u) {
let j = u[i].split('=');
get[j[0]] = decodeURIComponent(j[1]);
}
return get;
} else {
return {};
}
};
export default class Detail extends Component {
......@@ -31,9 +31,9 @@ export default class Detail extends Component {
const { record } = state;
id = record.id;
}
if(!id){
id = getUrlInfo()?.id;
}
if (!id) {
id = getUrlInfo()?.id;
}
this.state = {
id,
};
......@@ -92,7 +92,7 @@ export default class Detail extends Component {
marginWidth="0"
marginHeight="0"
onLoad={this.showAll}
allowtransparency="yes"
allowtransparency="yes"
seamless
scrolling={'no'}
style={{
......
......@@ -90,7 +90,7 @@ export default class Detail extends Component {
marginWidth="0"
marginHeight="0"
onLoad={this.showAll}
allowtransparency="yes"
allowtransparency="yes"
seamless
scrolling={'no'}
style={{
......
......@@ -5,117 +5,125 @@ import * as service from '@/baseComponent/UploadImgDiy/service';
import PropTypes from 'prop-types';
export default class ButtonUpload extends Component {
constructor(props) {
super(props);
constructor(props) {
super(props);
this.state = {
fileSize: props.fileSize || 2,
loading: false,
};
}
this.state = {
fileSize: props.fileSize || 2,
loading: false,
};
}
checkSize(file) {
const { fileSize } = this.state;
let flag = false;
checkSize(file) {
const { fileSize } = this.state;
let flag = false;
if (fileSize && file.size / 1024 / 1024 > fileSize) {
message.error(`单个文件大小不能超过${fileSize}MB!`);
flag = true;
}
if (fileSize && file.size / 1024 / 1024 > fileSize) {
message.error(`单个文件大小不能超过${fileSize}MB!`);
flag = true;
}
return flag;
}
return flag;
}
uploadFile = () => {
const { onChange } = this.props;
const file = this.fileInput.files[this.fileInput.files.length - 1];
if (!file || this.checkSize(file)) {
return;
}
this.setState({
loading: true,
});
service.uploadFile({
file: file,
}).then(res => {
this.setState({
loading: false,
});
if (res) {
message.success('上传成功');
let data = {
files: [
{
path: res.url,
name: file.name,
},
],
};
onChange && onChange(data, this.fileInput);
}
});
};
uploadFile = () => {
const { onChange } = this.props;
const file = this.fileInput.files[this.fileInput.files.length - 1];
if (!file || this.checkSize(file)) {
return;
}
this.setState({
loading: true,
});
service
.uploadFile({
file: file,
})
.then((res) => {
this.setState({
loading: false,
});
if (res) {
message.success('上传成功');
let data = {
files: [
{
path: res.url,
name: file.name,
},
],
};
onChange && onChange(data, this.fileInput);
}
});
};
selectFile = () => {
this.fileInput.click();
};
selectFile = () => {
this.fileInput.click();
};
render() {
const { accept, buttonName, buttonClassName, value, readOnly, disabled } = this.props;
const { loading } = this.state;
const viewDom = <a href={value}
target="_blank">点击查看</a>;
if (readOnly || disabled) {
if(typeof value === 'object'){
if(Array.isArray(value.files) && value.files.length){
return <a href={value.files[0].path}
target="_blank">点击查看</a>;
}else{
return null;
}
}
if (value) {
return viewDom;
}
return null;
}
return (
<Fragment>
<label>
<ButtonDiy name={loading ? '上传中' : buttonName}
loading={loading}
handleClick={this.selectFile}
className={buttonClassName}
/>
<input type="file"
accept={accept}
style={{ display: 'none' }}
onChange={this.uploadFile}
ref={input => {
this.fileInput = input;
}}
/>
{this.fileInput && this.fileInput.value.split('\\').pop()
|| value
|| <span style={{ color: '#D2D2D2' }}>未选择任何文件</span>}
</label>
</Fragment>
);
}
render() {
const { accept, buttonName, buttonClassName, value, readOnly, disabled } = this.props;
const { loading } = this.state;
const viewDom = (
<a href={value} target="_blank">
点击查看
</a>
);
if (readOnly || disabled) {
if (typeof value === 'object') {
if (Array.isArray(value.files) && value.files.length) {
return (
<a href={value.files[0].path} target="_blank">
点击查看
</a>
);
} else {
return null;
}
}
if (value) {
return viewDom;
}
return null;
}
return (
<Fragment>
<label>
<ButtonDiy
name={loading ? '上传中' : buttonName}
loading={loading}
handleClick={this.selectFile}
className={buttonClassName}
/>
<input
type="file"
accept={accept}
style={{ display: 'none' }}
onChange={this.uploadFile}
ref={(input) => {
this.fileInput = input;
}}
/>
{(this.fileInput && this.fileInput.value.split('\\').pop()) ||
value || <span style={{ color: '#D2D2D2' }}>未选择任何文件</span>}
</label>
</Fragment>
);
}
}
ButtonUpload.propTypes = {
fileSize: PropTypes.number, // 文件大小限制
accept: PropTypes.string, // 上传类型限制
buttonName: PropTypes.string, // 上传按钮名称
buttonClassName: PropTypes.string, //按钮样式
onChange: PropTypes.func, // 上传成功回调
fileSize: PropTypes.number, // 文件大小限制
accept: PropTypes.string, // 上传类型限制
buttonName: PropTypes.string, // 上传按钮名称
buttonClassName: PropTypes.string, //按钮样式
onChange: PropTypes.func, // 上传成功回调
};
ButtonUpload.defaultProps = {
fileSize: 2,
accept: '',
buttonName: '选择文件',
buttonClassName: 'defaultBlue',
onChange: () => {
},
fileSize: 2,
accept: '',
buttonName: '选择文件',
buttonClassName: 'defaultBlue',
onChange: () => {},
};
差异被折叠。
差异被折叠。
差异被折叠。
差异被折叠。
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论