提交 a951c1f3 authored 作者: wanyielin's avatar wanyielin

上传判断

上级 cc906839
......@@ -10,6 +10,8 @@ import TableCom from '../tableCompon'
import { Toast } from 'antd-mobile'
import router from 'umi/router'
import IsNewTable from './isNewTable';
import maintain from '@/assets/maintain.png'
import moment from 'moment'
export default class ZdyTable extends Component {
constructor(props) {
super(props)
......@@ -36,7 +38,7 @@ export default class ZdyTable extends Component {
}
}
componentDidMount(){
componentDidMount() {
let {
postData, // 数据源
isCg, // 用户点击草稿页面进入
......@@ -357,8 +359,30 @@ export default class ZdyTable extends Component {
}
render() {
let { width, isBorder, sqlData, mapData, defaultBinds, defaultValues, items, init, currentFormKey, isEdit, datas, isReady, formConfig, formCode, formId } = this.state
let { border, get, obj, index, fatherCode,routerState } = this.props
let { width,
isBorder,
sqlData,
mapData,
defaultBinds,
defaultValues,
items,
init,
currentFormKey,
isEdit,
datas,
isReady,
formConfig,
formCode,
formId
} = this.state
let { border,
get,
obj,
index,
fatherCode,
routerState,
postData,
} = this.props
let style = {}
if (formConfig.style != null) {
try {
......@@ -381,193 +405,239 @@ export default class ZdyTable extends Component {
};
const max = this.countMax(items)
const borderStyle = {
borderRight: "1px solid gray", borderTop: "1px solid gray", borderLeft: "1px solid gray", borderBottom: "1px solid gray"
borderRight: "1px solid gray",
borderTop: "1px solid gray",
borderLeft: "1px solid gray",
borderBottom: "1px solid gray"
}
const borderStyleTwo = { // 处理隐藏组件边框样式问题
borderRight: "1px solid gray", borderLeft: "1px solid gray"
}
let updateTime
const styleDiv = this.props.height ? { overflow: "auto", width: "100%", height: this.props.height } : { overflow: "auto", width: "100%" }
if (!isReady) return <></>
if (this.props.postData?.isUpdate) {
updateTime = moment(+this.props.postData?.updateTime).format('llll')
}
switch (get) {
case 'web':
return (
<Form
className="login-form" >
{isEdit && defaultBinds ? Object.keys(defaultBinds).map((k) => {
const r = defaultBinds[k]
if (r.columnIds == null || r.columnIds.length < 2 || r.sqls == null || r.sqls.length < 2) {
return ""
}
const name = r.columnIds[r.columnIds.length - 1]
const key = r.sqls[r.sqls.length - 1]
const value = defaultValues[key]
return (<>
{this.props.postData?.isUpdate ?
<div style={{ margin: '100px 24px 24px' }}>
<div style={{ textAlign: 'center' }}>
<img style={{ marginRight: 30 }} src={maintain}></img>
</div>
<p style={{
textAlign: "center",
width: '100%',
fontSize: '16px',
fontWeight: 'bold',
color: '#666666',
}}
>
{updateTime !== 'Invalid date' ?
`升级维护中,预计${updateTime ?? '一万年'}恢复使用,请耐心等待。` :
'请耐心等待'}
</p>
</div>
:
<Form
className="login-form" >
{isEdit && defaultBinds ? Object.keys(defaultBinds).map((k) => {
const r = defaultBinds[k]
if (r.columnIds == null || r.columnIds.length < 2 || r.sqls == null || r.sqls.length < 2) {
return ""
}
const name = r.columnIds[r.columnIds.length - 1]
const key = r.sqls[r.sqls.length - 1]
const value = defaultValues[key]
if (value == null) {
return ""
}
return this.props.form.getFieldDecorator(name, {
initialValue: value
})(<Input type="hidden" />);
}) : ""}
<Row>
<Col span={24}>
<div
style={styleDiv}
ref={ref => { this.root = ref }}
>
<table
style={{
overflow: "auto",
margin: max * width > 550 ? "auto" : '',
...style
}}
border={border}
cellSpacing="0"
cellPadding="0" >
<tbody>
{items.map((row, i) => {
const allhidden = this.checkAllHidden(row)
return <tr key={i}>
{row.map((cell, j) => {
let styles = {}
if (cell.content && cell.content.styles) {
try {
styles = JSON.parse(cell.content.styles)
} catch (e) {
console.log(`第${i}行第${j}列样式配置有误,${e}`)
}
}
return !allhidden && cell.hidden ?
""
: <td
width={
i == 0 ?
((cell.content != null && cell.content.cwidth != null ? cell.content.cwidth : width) * (cell.col ? cell.col : 1))
: width * (cell.col ? cell.col : 1)}
rowSpan={cell.row}
colSpan={cell.col}
key={j}
style={{
overflow: "auto",
textAlign: cell.content && cell.content.calign ? cell.content.calign : "left",
...isBorder ? (cell?.content?.comName == "InputHidden" || !cell?.content?.comName ? {} : borderStyle) : {},
...styles
}} >
<TableCom
formCode={formCode} // 当前表单code
formId={formId} // 当前表单Id
i={i} // 当前组件下标
j={j} // 当前行数下班
fatherCode={fatherCode}
index={index}
fatherObj={this.props.fatherObj}
datas={datas}
uuid={cell.uuid}
isEdit={isEdit}
formKey={currentFormKey}
init={init}
get={get} // 区分移动端或wen端
json={cell.content}
obj={obj || {}} // 是否存在默认值
mapData={mapData}
form={this.props.form} // antd form控件
sqlData={sqlData}
defaultValues={defaultValues || {}} // 接口中的默认值
routerState={routerState} // 兼容表单设计器路由传参
/>
</td>
}
)
if (value == null) {
return ""
}
return this.props.form.getFieldDecorator(name, {
initialValue: value
}
})(<Input type="hidden" />);
</tr>
}) : ""}
})}
</tbody>
</table>
<Row>
<Col span={24}>
<div
style={styleDiv}
ref={ref => { this.root = ref }}
>
<table
style={{
overflow: "auto",
margin: max * width > 550 ? "auto" : '',
...style
}}
border={border}
cellSpacing="0"
cellPadding="0" >
<tbody>
{items.map((row, i) => {
const allhidden = this.checkAllHidden(row)
return <tr key={i}>
{row.map((cell, j) => {
let styles = {}
if (cell.content && cell.content.styles) {
try {
styles = JSON.parse(cell.content.styles)
} catch (e) {
console.log(`第${i}行第${j}列样式配置有误,${e}`)
}
}
return !allhidden && cell.hidden ?
""
: <td
width={
i == 0 ?
((cell.content != null && cell.content.cwidth != null ? cell.content.cwidth : width) * (cell.col ? cell.col : 1))
: width * (cell.col ? cell.col : 1)}
rowSpan={cell.row}
colSpan={cell.col}
key={j}
style={{
overflow: "auto",
textAlign: cell.content && cell.content.calign ? cell.content.calign : "left",
...isBorder ? (cell?.content?.comName == "InputHidden" || !cell?.content?.comName ? {} : borderStyle) : {},
...styles
}} >
<TableCom
formCode={formCode} // 当前表单code
formId={formId} // 当前表单Id
i={i} // 当前组件下标
j={j} // 当前行数下班
fatherCode={fatherCode}
index={index}
fatherObj={this.props.fatherObj}
datas={datas}
uuid={cell.uuid}
isEdit={isEdit}
formKey={currentFormKey}
init={init}
get={get} // 区分移动端或wen端
json={cell.content}
obj={obj || {}} // 是否存在默认值
mapData={mapData}
form={this.props.form} // antd form控件
sqlData={sqlData}
defaultValues={defaultValues || {}} // 接口中的默认值
routerState={routerState} // 兼容表单设计器路由传参
/>
</td>
}
)
}
</tr>
})}
</tbody>
</table>
{style.pageBreakAfter != null ? <div style={{ pageBreakAfter: style.pageBreakAfter }}></div> : ""}
</div>
</Col>
</Row>
</Form>
{style.pageBreakAfter != null ? <div style={{ pageBreakAfter: style.pageBreakAfter }}></div> : ""}
</div>
</Col>
</Row>
</Form>}
</>
)
case 'mobile':
return (
<Form {...formItemLayout} id='mobile_table' className="login-form">
{defaultBinds ? Object.keys(defaultBinds).map((k) => {
const r = defaultBinds[k]
if (r.columnIds == null || r.columnIds.length < 2 || r.sqls == null || r.sqls.length < 2) {
return ""
}
const name = r.columnIds[r.columnIds.length - 1]
const key = r.sqls[r.sqls.length - 1]
const value = defaultValues[key]
if (value == null) {
return ""
return (<>
{this.props.postData?.isUpdate ?
<div style={{ margin: '100px 24px 24px' }}>
<div style={{ textAlign: 'center' }}>
<img style={{ width: '100%' }} src={maintain}></img>
</div>
<p style={{
textAlign: "center",
width: '100%',
fontSize: '16px',
fontWeight: 'bold',
color: '#666666',
}}
>
{updateTime !== 'Invalid date' ?
`升级维护中,预计${updateTime ?? '一万年'}恢复使用,请耐心等待。` :
'请耐心等待'}
</p>
</div>
:
<Form {...formItemLayout} id='mobile_table' className="login-form">
{defaultBinds ? Object.keys(defaultBinds).map((k) => {
const r = defaultBinds[k]
if (r.columnIds == null || r.columnIds.length < 2 || r.sqls == null || r.sqls.length < 2) {
return ""
}
const name = r.columnIds[r.columnIds.length - 1]
const key = r.sqls[r.sqls.length - 1]
const value = defaultValues[key]
if (value == null) {
return ""
}
return this.props.form.getFieldDecorator(name, {
initialValue: value
})(<Input type="hidden" />);
}) : ""}
{
items.map((item, i) => {
const allhidden = this.checkAllHidden(items)
return (<div
key={i}
style={{
marginTop: 0,
background: '#ffffff',
paddingLeft: 12,
width: '100%',
flexWrap: 'wrap',
...style
}}>
{
item.map((ary, j) => {
return !allhidden && ary.hidden ? ""
: <><TableCom
formCode={formCode}
formId={formId}
i={i}
j={j}
index={index}
fatherCode={fatherCode}
datas={datas}
isEdit={isEdit}
fatherObj={this.props.fatherObj}
formKey={currentFormKey}
init={init}
get={get}
key={j}
sqlData={sqlData}
obj={obj || {}}
form={this.props.form}
mapData={mapData}
json={ary.content}
uuid={ary.uuid}
routerState={routerState} // 兼容表单设计器路由传参
defaultValues={defaultValues || {}} /></>
})
}
</div>)
})
}
return this.props.form.getFieldDecorator(name, {
initialValue: value
})(<Input type="hidden" />);
}) : ""}
{
items.map((item, i) => {
const allhidden = this.checkAllHidden(items)
return (<div
key={i}
style={{
marginTop: 0,
background: '#ffffff',
paddingLeft: 12,
width: '100%',
flexWrap: 'wrap',
...style
}}>
{
item.map((ary, j) => {
return !allhidden && ary.hidden ? ""
: <><TableCom
formCode={formCode}
formId={formId}
i={i}
j={j}
index={index}
fatherCode={fatherCode}
datas={datas}
isEdit={isEdit}
fatherObj={this.props.fatherObj}
formKey={currentFormKey}
init={init}
get={get}
key={j}
sqlData={sqlData}
obj={obj || {}}
form={this.props.form}
mapData={mapData}
json={ary.content}
uuid={ary.uuid}
routerState={routerState} // 兼容表单设计器路由传参
defaultValues={defaultValues || {}} /></>
})
}
</div>)
})
}
</Form>
</Form>}
</>
)
}
}
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论