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

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

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