提交 d80fc563 authored 作者: chlolch's avatar chlolch

修改bug

上级 7f903274
...@@ -9,6 +9,7 @@ import { Form, Row, Col, Input, message } from 'antd'; ...@@ -9,6 +9,7 @@ import { Form, Row, Col, Input, message } from 'antd';
import { Toast } from 'antd-mobile'; import { Toast } from 'antd-mobile';
import router from 'umi/router'; import router from 'umi/router';
import moment from 'moment'; import moment from 'moment';
import { HyperFormula } from 'hyperformula';
import TableCom from '../tableCompon'; import TableCom from '../tableCompon';
import IsNewTable from './isNewMobileTable'; import IsNewTable from './isNewMobileTable';
import maintain from '../assets/maintain.png'; import maintain from '../assets/maintain.png';
...@@ -29,6 +30,7 @@ export default class ZdyTable extends Component { ...@@ -29,6 +30,7 @@ export default class ZdyTable extends Component {
sqlData: {}, sqlData: {},
defaultValues: {}, defaultValues: {},
currentFormKey: null, currentFormKey: null,
currentFormTitle:null,
items: [], items: [],
init: this.props.init || {}, init: this.props.init || {},
datas: {}, datas: {},
...@@ -56,6 +58,8 @@ export default class ZdyTable extends Component { ...@@ -56,6 +58,8 @@ export default class ZdyTable extends Component {
isReady: true, isReady: true,
formConfig: { ...this.state.formConfig, style: this.props.style }, formConfig: { ...this.state.formConfig, style: this.props.style },
}); });
this.initExcel({datas:this.props.datas,trees:this.props.trees})
return; return;
} }
...@@ -86,13 +90,15 @@ export default class ZdyTable extends Component { ...@@ -86,13 +90,15 @@ export default class ZdyTable extends Component {
} }
const obj = JSON.parse(val.form.content); const obj = JSON.parse(val.form.content);
const xxx = obj.datas[obj.init]; const xxx = obj.datas[obj.init];
const fk= this.props.table ? val.formKey : obj.init;
this.setState({ this.setState({
datas: obj.datas, datas: obj.datas,
width: this.props.table ? obj.datas[val.formKey].width : xxx.width, width: this.props.table ? obj.datas[val.formKey].width : xxx.width,
isBorder: this.props.table ? obj.datas[val.formKey].isBorder : xxx.isBorder, isBorder: this.props.table ? obj.datas[val.formKey].isBorder : xxx.isBorder,
isRowCol: this.props.table ? obj.datas[val.formKey].isRowCol : xxx.isRowCol, isRowCol: this.props.table ? obj.datas[val.formKey].isRowCol : xxx.isRowCol,
mapData, mapData,
currentFormKey: this.props.table ? val.formKey : obj.init, currentFormKey: fk,
currentFormTitle:getCurrentFormTitle(obj,fk),
sqlData, sqlData,
isEdit: !this.props.formKey, isEdit: !this.props.formKey,
items: this.props.table ? obj.datas[val.formKey].items : xxx.items, items: this.props.table ? obj.datas[val.formKey].items : xxx.items,
...@@ -100,7 +106,7 @@ export default class ZdyTable extends Component { ...@@ -100,7 +106,7 @@ export default class ZdyTable extends Component {
appId: val.appId, appId: val.appId,
isReady: true, isReady: true,
formConfig: xxx, formConfig: xxx,
}); },()=> this.initExcel(obj));
return; return;
} }
if (isCg === 'yes') { if (isCg === 'yes') {
...@@ -144,6 +150,7 @@ export default class ZdyTable extends Component { ...@@ -144,6 +150,7 @@ export default class ZdyTable extends Component {
datas: obj.datas, datas: obj.datas,
isEdit: !this.props.formKey, isEdit: !this.props.formKey,
currentFormKey: obj.init, currentFormKey: obj.init,
currentFormTitle:getCurrentFormTitle(obj,obj.init),
width: xxx.width, width: xxx.width,
isBorder: xxx.isBorder, isBorder: xxx.isBorder,
isRowCol: xxx.isRowCol, isRowCol: xxx.isRowCol,
...@@ -156,7 +163,7 @@ export default class ZdyTable extends Component { ...@@ -156,7 +163,7 @@ export default class ZdyTable extends Component {
defaultBinds: this.props.table defaultBinds: this.props.table
? obj.datas[val.taskFormKey].defaultBinds ? obj.datas[val.taskFormKey].defaultBinds
: xxx.defaultBinds, : xxx.defaultBinds,
}); },()=> this.initExcel(obj));
return; return;
} }
if ( if (
...@@ -192,6 +199,11 @@ export default class ZdyTable extends Component { ...@@ -192,6 +199,11 @@ export default class ZdyTable extends Component {
} }
const obj = JSON.parse(val.unifiedServicePatternModel.content); const obj = JSON.parse(val.unifiedServicePatternModel.content);
const xxx = obj.datas[this.props.formKey ? this.props.formKey : obj.init]; // 是否是存在历史表单传入值 const xxx = obj.datas[this.props.formKey ? this.props.formKey : obj.init]; // 是否是存在历史表单传入值
const fk=this.props.formKey
? this.props.formKey
: val.taskFormKey
? val.taskFormKey
: obj.init
this.setState( this.setState(
{ {
appId: val.id, appId: val.id,
...@@ -202,11 +214,8 @@ export default class ZdyTable extends Component { ...@@ -202,11 +214,8 @@ export default class ZdyTable extends Component {
sqlData, sqlData,
defaultValues: val.unifiedServicePatternModel.defaultValues, defaultValues: val.unifiedServicePatternModel.defaultValues,
isEdit: !this.props.formKey, isEdit: !this.props.formKey,
currentFormKey: this.props.formKey currentFormKey: fk,
? this.props.formKey currentFormTitle:getCurrentFormTitle(obj,fk),
: val.taskFormKey
? val.taskFormKey
: obj.init,
defaultBinds: this.props.table defaultBinds: this.props.table
? obj.datas[val.taskFormKey].defaultBinds ? obj.datas[val.taskFormKey].defaultBinds
: xxx.defaultBinds, : xxx.defaultBinds,
...@@ -226,13 +235,57 @@ export default class ZdyTable extends Component { ...@@ -226,13 +235,57 @@ export default class ZdyTable extends Component {
if (isQRCode) { if (isQRCode) {
this.props.form.setFieldsValue(formDeafault); this.props.form.setFieldsValue(formDeafault);
} }
this.initExcel(obj)
}, },
); );
} catch (e) { } catch (e) {
console.log('公式配置有误', e); console.log('公式配置有误', e);
} }
} }
hfInstance;
initExcel=(configs)=>{
if(configs==null) return
const sheetData = {}
for(var key in configs.trees){
const tr=configs.trees[key]
const data= configs.datas[tr.key]
const all = []
for(var i=0;i<data.items.length;i++){
const row=data.items[i]
const r=[]
for(var j=0;j<row.length;j++){
const col=row[j]
if(col.content?.comName=="Excel"){
r.push(col.content.initialValue)
}else{
r.push('')
}
}
all.push(r)
}
sheetData[tr.title]=all
}
const hfInstance = HyperFormula.buildFromSheets(sheetData, {});
this.hfInstance=hfInstance
}
getCellValue=(i,j,currentTitle)=>{
if(this.hfInstance&&currentTitle){
let x = this.hfInstance.getCellValue({ col: j, row: i, sheet: this.hfInstance.getSheetId(currentTitle) })
if(x&&x.value!=null){
x=x.value
}
return x;
}
}
componentWillReceiveProps(nextProps) { componentWillReceiveProps(nextProps) {
const { const {
postData, // 数据源 postData, // 数据源
...@@ -405,8 +458,17 @@ export default class ZdyTable extends Component { ...@@ -405,8 +458,17 @@ export default class ZdyTable extends Component {
}); });
return max; return max;
}; };
getCurrentFormTitle=(obj,key)=>{
const {trees}=obj
for(var i=0;i<trees.length;i++){
if(trees[i].key==key){
return trees[i].title
}
}
}
render() { render() {
const { const {
width, width,
isRowCol, isRowCol,
...@@ -419,6 +481,7 @@ export default class ZdyTable extends Component { ...@@ -419,6 +481,7 @@ export default class ZdyTable extends Component {
init, init,
modalTitle, modalTitle,
currentFormKey, currentFormKey,
currentFormTitle,
isEdit, isEdit,
datas, datas,
isReady, isReady,
...@@ -620,6 +683,7 @@ export default class ZdyTable extends Component { ...@@ -620,6 +683,7 @@ export default class ZdyTable extends Component {
}} }}
> >
<TableCom <TableCom
getCellValue={this.getCellValue}
isWebPrintEnd={isWebPrintEnd} isWebPrintEnd={isWebPrintEnd}
isWebPrint={isWebPrint} isWebPrint={isWebPrint}
isPrint={this.props.isPrint} isPrint={this.props.isPrint}
...@@ -638,6 +702,7 @@ export default class ZdyTable extends Component { ...@@ -638,6 +702,7 @@ export default class ZdyTable extends Component {
uuid={cell.uuid} uuid={cell.uuid}
isEdit={isEdit} isEdit={isEdit}
formKey={currentFormKey} formKey={currentFormKey}
currentFormTitle={currentFormTitle}
init={init} init={init}
get={get} // 区分移动端或wen端 get={get} // 区分移动端或wen端
json={cell.content} json={cell.content}
...@@ -722,6 +787,7 @@ export default class ZdyTable extends Component { ...@@ -722,6 +787,7 @@ export default class ZdyTable extends Component {
}) })
: ''} : ''}
<IsNewTable <IsNewTable
getCellValue={this.getCellValue}
taskAssignee={taskAssignee} // 提交人 taskAssignee={taskAssignee} // 提交人
userId={userId} userId={userId}
isPreview={isPreview} isPreview={isPreview}
...@@ -736,6 +802,7 @@ export default class ZdyTable extends Component { ...@@ -736,6 +802,7 @@ export default class ZdyTable extends Component {
datas={datas} datas={datas}
isEdit={isEdit} isEdit={isEdit}
currentFormKey={currentFormKey} currentFormKey={currentFormKey}
currentFormTitle={currentFormTitle}
init={init} init={init}
get={get} get={get}
obj={obj} obj={obj}
......
...@@ -38,6 +38,8 @@ export default class isNewTable extends Component { ...@@ -38,6 +38,8 @@ export default class isNewTable extends Component {
modalInit, modalInit,
concealModel, concealModel,
taskAssignee, taskAssignee,
currentFormTitle,
getCellValue
} = this.props; } = this.props;
if (!isEdit) { if (!isEdit) {
// 展示栏 暂不做处理 // 展示栏 暂不做处理
...@@ -94,6 +96,8 @@ export default class isNewTable extends Component { ...@@ -94,6 +96,8 @@ export default class isNewTable extends Component {
isEdit={isEdit} isEdit={isEdit}
fatherObj={this.props.fatherObj} fatherObj={this.props.fatherObj}
formKey={currentFormKey} formKey={currentFormKey}
currentFormTitle
getCellValue
init={init} init={init}
get={get} get={get}
key={j} key={j}
...@@ -166,6 +170,8 @@ export default class isNewTable extends Component { ...@@ -166,6 +170,8 @@ export default class isNewTable extends Component {
isEdit={isEdit} isEdit={isEdit}
fatherObj={this.props.fatherObj} fatherObj={this.props.fatherObj}
formKey={currentFormKey} formKey={currentFormKey}
currentFormTitle
getCellValue
init={init} init={init}
get={get} get={get}
key={j} key={j}
...@@ -210,6 +216,8 @@ export default class isNewTable extends Component { ...@@ -210,6 +216,8 @@ export default class isNewTable extends Component {
isEdit={isEdit} isEdit={isEdit}
fatherObj={this.props.fatherObj} fatherObj={this.props.fatherObj}
formKey={currentFormKey} formKey={currentFormKey}
currentFormTitle
getCellValue
init={init} init={init}
get={get} get={get}
key={j} key={j}
......
...@@ -1421,9 +1421,11 @@ export default class tableCom extends Component { ...@@ -1421,9 +1421,11 @@ export default class tableCom extends Component {
isEdit, isEdit,
datas, datas,
taskAssignee, taskAssignee,
userId, userId,i,
j, j,
isPreview, isPreview,
currentFormTitle,
getCellValue
} = this.props; } = this.props;
const { options, labels, selectDis, modalCode, modalTitle, modalInit, modalProps } = this.state; const { options, labels, selectDis, modalCode, modalTitle, modalInit, modalProps } = this.state;
...@@ -1498,7 +1500,12 @@ export default class tableCom extends Component { ...@@ -1498,7 +1500,12 @@ export default class tableCom extends Component {
</> </>
); );
} }
if (json.comName == 'Label' || json.comName == 'Excel') { if(json.comName=='Excel'){
const value= getCellValue(i,j,currentFormTitle)
const xx=<div style={{textAlign:"center",height:value==null?20:null}}>{value}</div>
return xx;
}
if (json.comName == 'Label') {
let uid; let uid;
if (this.props.fatherCode != null) { if (this.props.fatherCode != null) {
uid = `${this.props.fatherCode}.[${this.props.index}].${this.props.uuid}`; uid = `${this.props.fatherCode}.[${this.props.index}].${this.props.uuid}`;
...@@ -1516,7 +1523,7 @@ export default class tableCom extends Component { ...@@ -1516,7 +1523,7 @@ export default class tableCom extends Component {
})(<Input type="hidden" />)} })(<Input type="hidden" />)}
<span <span
style={{ style={{
whiteSpace: json.comName == 'Excel' ? 'nowrap' : 'normal',
fontWeight: get == 'mobile' ? 'bold' : '', fontWeight: get == 'mobile' ? 'bold' : '',
marginRight: get == 'mobile' ? 12 : '', marginRight: get == 'mobile' ? 12 : '',
}} }}
...@@ -1534,7 +1541,7 @@ export default class tableCom extends Component { ...@@ -1534,7 +1541,7 @@ export default class tableCom extends Component {
})(<Input type="hidden" />)} })(<Input type="hidden" />)}
<span <span
style={{ style={{
whiteSpace: json.comName == 'Excel' ? 'nowrap' : 'normal',
fontWeight: get == 'mobile' ? 'bold' : '', fontWeight: get == 'mobile' ? 'bold' : '',
marginRight: get == 'mobile' ? 12 : '', marginRight: get == 'mobile' ? 12 : '',
}} }}
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论