提交 03b5fe22 authored 作者: 钟是志's avatar 钟是志

列表组件 formList 中的showDiv 没得值的bug

上级 10bbf581
...@@ -7,10 +7,8 @@ ...@@ -7,10 +7,8 @@
* @FilePath: \one_stop_front\src\components\libs\TableList.js * @FilePath: \one_stop_front\src\components\libs\TableList.js
*/ */
import React from 'react'; import React from 'react';
import { Tree, Table, Spin } from 'antd';
import FormList from './formList'; import FormList from './formList';
import TreeList from './formList/TreeList'; import TreeList from './formList/TreeList';
import { connect } from 'dva';
export default class TableList extends React.Component { export default class TableList extends React.Component {
constructor(props) { constructor(props) {
...@@ -32,16 +30,35 @@ export default class TableList extends React.Component { ...@@ -32,16 +30,35 @@ export default class TableList extends React.Component {
onChange(Object.assign({}, this.state, changedValue)); onChange(Object.assign({}, this.state, changedValue));
} }
}; };
componentWillReceiveProps(nextProps) {
// Should be a controlled component.
if ('value' in nextProps) {
const value = nextProps.value;
this.setState(value);
}
}
render() { static getDerivedStateFromProps(nextProps, prevState) {
// ...
if('value' in nextProps){
return {...nextProps.value};
}
return null;
}
componentDidUpdate(prevProps, prevState) {
if(prevState?.columns !== this.state.columns){
this.setState({
showNo: true,
}, () => {
setTimeout(()=>{
this.setState({
showNo: false,
});
}, 1000);
});
}
}
render() {
const { isTree, json } = this.props; const { isTree, json } = this.props;
const { showNo } = this.state;
if(showNo){
return null;
}
return isTree ? ( return isTree ? (
<TreeList <TreeList
json={json} json={json}
...@@ -69,7 +86,7 @@ export default class TableList extends React.Component { ...@@ -69,7 +86,7 @@ export default class TableList extends React.Component {
isHiddenPage={this.props.isHiddenPage != null ? this.props.isHiddenPage : false} isHiddenPage={this.props.isHiddenPage != null ? this.props.isHiddenPage : false}
loading={this.props.loading} loading={this.props.loading}
pageSize={this.props.pageSize || 10} pageSize={this.props.pageSize || 10}
value={this.state} value={{...this.state}}
notShowBack={true} notShowBack={true}
rights={this.props.rights || []} rights={this.props.rights || []}
objCode={this.props.objCode} objCode={this.props.objCode}
......
...@@ -63,7 +63,6 @@ class StandardTable extends Component { ...@@ -63,7 +63,6 @@ class StandardTable extends Component {
render() { render() {
const { selectedRowKeys, needTotalList } = this.state; const { selectedRowKeys, needTotalList } = this.state;
const { const {
data: { list, pagination }, data: { list, pagination },
loading, loading,
......
...@@ -323,6 +323,9 @@ class FormList extends React.Component { ...@@ -323,6 +323,9 @@ class FormList extends React.Component {
} }
}; };
//渲染值 //渲染值
componentDidMount() { componentDidMount() {
const { dispatch, isFormCom, isSelect, callback, valueName } = this.props; const { dispatch, isFormCom, isSelect, callback, valueName } = this.props;
...@@ -330,7 +333,7 @@ class FormList extends React.Component { ...@@ -330,7 +333,7 @@ class FormList extends React.Component {
if (this.props.objCode) { if (this.props.objCode) {
const { dispatch, objCode, sql } = this.props; const { dispatch, objCode, sql } = this.props;
if (objCode == 1 || objCode == '1') { if (Number(objCode) === 1) {
this.initColumn(); this.initColumn();
} else { } else {
dispatch({ dispatch({
...@@ -396,10 +399,22 @@ class FormList extends React.Component { ...@@ -396,10 +399,22 @@ class FormList extends React.Component {
custom = this.props.value ? Base16Encode(JSON.stringify(this.props.value)) : null; custom = this.props.value ? Base16Encode(JSON.stringify(this.props.value)) : null;
// componentDidUpdate(prevProps, prevState) {
// console.log(this.props?.value?.columns, prevProps?.props?.value?.columns);
// if(this.props?.value && this.props?.value?.columns !== prevProps?.props?.value?.columns){
// if (Number(this.props.objCode) === 1) {
// this.initColumn();
// }
// }
// return null;
// }
componentWillReceiveProps(nextProps) { componentWillReceiveProps(nextProps) {
const b = nextProps.value || {}; const b = nextProps.value || {};
const a = this.props.value || {}; const a = this.props.value || {};
const jsonb = JSON.stringify(b); const jsonb = JSON.stringify(b);
const jsona = JSON.stringify(a); const jsona = JSON.stringify(a);
...@@ -429,16 +444,15 @@ class FormList extends React.Component { ...@@ -429,16 +444,15 @@ class FormList extends React.Component {
} }
initColumn = () => { initColumn = () => {
const { dispatch, isFormCom, isSelect, callback, valueName } = this.props; const { dispatch, value, objCode} = this.props;
const { rights, columnRights } = this.state; const { rights, columnRights } = this.state;
if (this.props.value && this.props.value.columns) { if (value && value.columns) {
this.columns = this.props.value.columns; this.columns = value.columns;
let cacheList = []; let cacheList = [];
let cacheChecked = []; let cacheChecked = [];
// 表头筛选逻辑 // 表头筛选逻辑
Array.isArray(this.props.value.columns) && Array.isArray(value.columns) &&
this.props.value.columns.map((item) => { value.columns.map((item) => {
if (item.dataIndex != null) { if (item.dataIndex != null) {
cacheList.push({ cacheList.push({
label: item.title, label: item.title,
...@@ -451,9 +465,9 @@ class FormList extends React.Component { ...@@ -451,9 +465,9 @@ class FormList extends React.Component {
this.setState({ this.setState({
checkedList: cacheChecked, checkedList: cacheChecked,
cacheColumns: cloneDeep(this.props.value.columns), cacheColumns: cloneDeep(value.columns),
}); });
if (this.props.objCode == 1 || this.props.objCode == '1') { if (Number(objCode) === 1) {
this.getPage(); this.getPage();
} else { } else {
dispatch({ dispatch({
...@@ -502,7 +516,7 @@ class FormList extends React.Component { ...@@ -502,7 +516,7 @@ class FormList extends React.Component {
return; return;
} }
if (this.props.objCode == 1 || this.props.objCode == '1') { if (Number(objCode) === 1) {
} else { } else {
dispatch({ dispatch({
type: 'formList/getHead', type: 'formList/getHead',
...@@ -646,6 +660,7 @@ class FormList extends React.Component { ...@@ -646,6 +660,7 @@ class FormList extends React.Component {
getPage = (params, values, callPage, pageNo) => { getPage = (params, values, callPage, pageNo) => {
const { objCode } = this.props;
if (this.columns == null || this.columns.length == 0) { if (this.columns == null || this.columns.length == 0) {
return; return;
} }
...@@ -662,7 +677,7 @@ class FormList extends React.Component { ...@@ -662,7 +677,7 @@ class FormList extends React.Component {
if (params.pageNo == null && callPage == null && this.props.value.getPage == null) return; if (params.pageNo == null && callPage == null && this.props.value.getPage == null) return;
} }
if (this.props.objCode && (this.props.objCode == '1' || this.props.objCode == 1)) { if (Number(objCode) === 1) {
if (callPage) { if (callPage) {
callPage(params, (data) => { callPage(params, (data) => {
if (!this.state.isReady) { if (!this.state.isReady) {
...@@ -878,7 +893,6 @@ class FormList extends React.Component { ...@@ -878,7 +893,6 @@ class FormList extends React.Component {
}; };
getItem = (isQuery, form, item, isAdd, formData, labelCol, wrapperCol) => { getItem = (isQuery, form, item, isAdd, formData, labelCol, wrapperCol) => {
const { groups, isView } = this.state; const { groups, isView } = this.state;
// console.log(item);
//如果隐藏的话 就用隐藏域放置 //如果隐藏的话 就用隐藏域放置
if (item.isHidden) { if (item.isHidden) {
return ( return (
...@@ -1149,7 +1163,7 @@ class FormList extends React.Component { ...@@ -1149,7 +1163,7 @@ class FormList extends React.Component {
render() { render() {
const { modalVisible, selectedRows, rights, data, isReady } = this.state; const { modalVisible, selectedRows, rights, data, isReady } = this.state;
if (!isReady) { if (!isReady) {
return ( return (
<div style={{ width: 20, margin: 'auto' }}> <div style={{ width: 20, margin: 'auto' }}>
<Spin /> <Spin />
...@@ -1168,7 +1182,6 @@ class FormList extends React.Component { ...@@ -1168,7 +1182,6 @@ class FormList extends React.Component {
value: { btns }, value: { btns },
loading, loading,
} = this.props; } = this.props;
const { showMobileDiv, isView } = this.state; const { showMobileDiv, isView } = this.state;
let scrollWidth = document.documentElement.clientWidth || document.body.clientWidth; //可使宽度 let scrollWidth = document.documentElement.clientWidth || document.body.clientWidth; //可使宽度
...@@ -1176,11 +1189,20 @@ class FormList extends React.Component { ...@@ -1176,11 +1189,20 @@ class FormList extends React.Component {
if (document.querySelector('#previewDiv')) { if (document.querySelector('#previewDiv')) {
isMobile = true; isMobile = true;
} }
// console.log(json);
let showDiv = 500;
if(document.getElementsByClassName('ant-layout-content')?.length){ // 这是大学工项目 容器元素的宽度
showDiv = document.getElementsByClassName('ant-layout-content')[0].clientWidth - 100;
}
if(json.twidth){ // 列表宽度配置项 在 组件的 扩展的配置里面
showDiv = json.twidth;
}
if(document.querySelector('#mobelDiv')){ // 这个是一站式的元素的宽度
showDiv = document.querySelector('#mobelDiv')?.parentNode.clientWidth;
}
console.log(showDiv);
let showDiv = json.twidth
? json.twidth
: document.querySelector('#mobelDiv') &&
document.querySelector('#mobelDiv')?.parentNode.clientWidth;
const parentMethods = { const parentMethods = {
handleAdd: this.handleAdd, handleAdd: this.handleAdd,
handleModalVisible: this.handleModalVisible, handleModalVisible: this.handleModalVisible,
...@@ -1198,7 +1220,9 @@ class FormList extends React.Component { ...@@ -1198,7 +1220,9 @@ class FormList extends React.Component {
!rights.includes('view') && !rights.includes('view') &&
!rights.includes('viewProcess') !rights.includes('viewProcess')
) { ) {
} else { }
else
{
let width = 0; let width = 0;
if (rights && rights.includes('viewProcess')) { if (rights && rights.includes('viewProcess')) {
width = width + 120; width = width + 120;
...@@ -1269,7 +1293,7 @@ class FormList extends React.Component { ...@@ -1269,7 +1293,7 @@ class FormList extends React.Component {
this.columns.push(column); this.columns.push(column);
} }
} }
// console.log(this.columns);
if (this.columns) { if (this.columns) {
/** /**
* 计算总长度 * 计算总长度
......
...@@ -1320,6 +1320,7 @@ export default class tableCom extends Component { ...@@ -1320,6 +1320,7 @@ export default class tableCom extends Component {
const { getFieldDecorator, getFieldError, getFieldProps } = this.props.form; const { getFieldDecorator, getFieldError, getFieldProps } = this.props.form;
const disabled = json != null ? json.disabled : false; const disabled = json != null ? json.disabled : false;
const permRank = json != null ? (json.permRank != null ? json.permRank : 0) : 0; const permRank = json != null ? (json.permRank != null ? json.permRank : 0) : 0;
// console.log(json.comName);
if (json == null) { if (json == null) {
return <></>; return <></>;
} }
...@@ -1810,6 +1811,8 @@ export default class tableCom extends Component { ...@@ -1810,6 +1811,8 @@ export default class tableCom extends Component {
dataColumn.base52 = this.props.uuid; dataColumn.base52 = this.props.uuid;
} }
} }
// console.log(json.comName);
switch (json.comName) { switch (json.comName) {
// 电子签章展示 // 电子签章展示
// case 'Signature': // case 'Signature':
...@@ -2652,7 +2655,7 @@ export default class tableCom extends Component { ...@@ -2652,7 +2655,7 @@ export default class tableCom extends Component {
/>, />,
); );
if (get === 'mobile') { if (get === 'mobile') {
console.log(json.vlds); // console.log(json.vlds);
cm = getFieldDecorator(dataColumn.base52, { cm = getFieldDecorator(dataColumn.base52, {
initialValue: initValue, initialValue: initValue,
rules: rules:
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论