提交 f333d3b9 authored 作者: tb53863844's avatar tb53863844

修改bug

上级 93a0e870
......@@ -5,7 +5,7 @@
*/
import React, { Component } from 'react';
import { Form, Row, Col, Input, message } from 'antd';
import UUID from 'react-native-uuid';
import { Toast } from 'antd-mobile';
import router from 'umi/router';
import moment from 'moment';
......@@ -30,7 +30,7 @@ export default class ZdyTable extends Component {
sqlData: {},
defaultValues: {},
currentFormKey: null,
currentFormTitle:null,
currentFormTitle: null,
items: [],
init: this.props.init || {},
datas: {},
......@@ -50,6 +50,7 @@ export default class ZdyTable extends Component {
isChild, // 是否为子表单
isQRCode = false, // 是否为二维码快捷发起
formDeafault = '', // 为二维码快捷发起默认值
} = this.props;
if (isPreview || isChild) {
......@@ -58,8 +59,9 @@ export default class ZdyTable extends Component {
...this.props,
isReady: true,
formConfig: { ...this.state.formConfig, style: this.props.style },
});
this.initExcel({datas:this.props.datas,trees:this.props.trees})
},()=> this.initExcel({ datas: this.props.datas, trees: this.props.trees }));
return;
}
......@@ -90,7 +92,7 @@ export default class ZdyTable extends Component {
}
const obj = JSON.parse(val.form.content);
const xxx = obj.datas[obj.init];
const fk= this.props.table ? val.formKey : obj.init;
const fk = this.props.table ? val.formKey : obj.init;
this.setState({
datas: obj.datas,
width: this.props.table ? obj.datas[val.formKey].width : xxx.width,
......@@ -98,7 +100,7 @@ export default class ZdyTable extends Component {
isRowCol: this.props.table ? obj.datas[val.formKey].isRowCol : xxx.isRowCol,
mapData,
currentFormKey: fk,
currentFormTitle:this.getCurrentFormTitle(obj,fk),
currentFormTitle: this.getCurrentFormTitle(obj, fk),
sqlData,
isEdit: !this.props.formKey,
items: this.props.table ? obj.datas[val.formKey].items : xxx.items,
......@@ -106,7 +108,7 @@ export default class ZdyTable extends Component {
appId: val.appId,
isReady: true,
formConfig: xxx,
},()=> this.initExcel(obj));
}, () => this.initExcel(obj));
return;
}
if (isCg === 'yes') {
......@@ -150,7 +152,7 @@ export default class ZdyTable extends Component {
datas: obj.datas,
isEdit: !this.props.formKey,
currentFormKey: obj.init,
currentFormTitle:this.getCurrentFormTitle(obj,obj.init),
currentFormTitle: this.getCurrentFormTitle(obj, obj.init),
width: xxx.width,
isBorder: xxx.isBorder,
isRowCol: xxx.isRowCol,
......@@ -163,7 +165,7 @@ export default class ZdyTable extends Component {
defaultBinds: this.props.table
? obj.datas[val.taskFormKey].defaultBinds
: xxx.defaultBinds,
},()=> this.initExcel(obj));
}, () => this.initExcel(obj));
return;
}
if (
......@@ -199,7 +201,7 @@ export default class ZdyTable extends Component {
}
const obj = JSON.parse(val.unifiedServicePatternModel.content);
const xxx = obj.datas[this.props.formKey ? this.props.formKey : obj.init]; // 是否是存在历史表单传入值
const fk=this.props.formKey
const fk = this.props.formKey
? this.props.formKey
: val.taskFormKey
? val.taskFormKey
......@@ -215,7 +217,7 @@ export default class ZdyTable extends Component {
defaultValues: val.unifiedServicePatternModel.defaultValues,
isEdit: !this.props.formKey,
currentFormKey: fk,
currentFormTitle:this.getCurrentFormTitle(obj,fk),
currentFormTitle: this.getCurrentFormTitle(obj, fk),
defaultBinds: this.props.table
? obj.datas[val.taskFormKey].defaultBinds
: xxx.defaultBinds,
......@@ -243,25 +245,95 @@ export default class ZdyTable extends Component {
}
}
hfInstance;
childExcel=(sheetData,datas,tr)=>{
if(tr.children==null||tr.children.length==0){
importExcel = (res) => {
const{datas,trees} = this.configs
const sheets = res.sheets
for (var s = 0; s < sheets.length; s++) {
const uuid = sheets[s].key;
const items = []
const cc = sheets[s].cells
for (var i = 0; i < cc.length; i++) {
const rows = [];
const rr = cc[i];
for (var j = 0; j < rr.length; j++) {
const c = rr[j];
if (c.value == null || c.value == '') {
rows.push({
uuid: 'id_' + UUID.v4().replace(/-/g, '2'),
row: c.rowSpan,
col: c.colSpan,
content: { comName: 'Excel', cwidth: c.width, cheight: c.height },
});
} else {
rows.push({
uuid: 'id_' + UUID.v4().replace(/-/g, '2'),
row: c.rowSpan,
col: c.colSpan,
content: { comName: 'Excel', initialValue: c.value, cwidth: c.width, cheight: c.height },
});
}
}
items.push(rows);
}
const charts = sheets[s].charts;
if (charts && charts.length > 0) {
const rows = [];
for (var j = 0; j < charts.length; j++) {
const chartModel = charts[j];
rows.push({
uuid: 'id_' + UUID.v4().replace(/-/g, '2'),
content: {
comName: 'Echart',
columnIds: { c1: [] },
labelSpan: 24,
wrapperSpan: 24,
isLabel: false,
formula: 'return ' + JSON.stringify(chartModel.option),
},
});
items.push(rows);
}
}
if(datas[uuid]==null){
trees.push({ title: sheets[s].name, key: uuid });
}
datas[uuid] = {
width: 400,
max: 1,
isBorder: true,
items: items,
};
}else{
for(var c=0;c<tr.children.length;c++){
this.childExcel(sheetData,datas,tr.children[c])
}
this.initExcel({ datas, trees })
console.log("公式导入excel成功")
}
const data= datas[tr.key]
hfInstance;
childExcel = (sheetData, datas, tr) => {
if (tr.children == null || tr.children.length == 0) {
} else {
for (var c = 0; c < tr.children.length; c++) {
this.childExcel(sheetData, datas, tr.children[c])
}
}
const data = 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"){
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{
} else {
r.push('')
}
......@@ -269,43 +341,49 @@ export default class ZdyTable extends Component {
all.push(r)
}
sheetData[tr.title]=all
sheetData[tr.title] = all
}
initExcel=(configs,callback)=>{
if(configs==null||configs.trees==null) return
}
configs
initExcel = (configs, callback) => {
if (configs == null || configs.trees == null) return
if(configs.trees!=null) this.configs=configs
const sheetData = {}
for(var key in configs.trees){
for (var key in configs.trees) {
const tr=configs.trees[key]
this.childExcel(sheetData,configs.datas,tr)
const tr = configs.trees[key]
this.childExcel(sheetData, configs.datas, tr)
}
const hfInstance = HyperFormula.buildFromSheets(sheetData, {});
this.hfInstance=hfInstance
if(callback)callback()
}
getCellValue=(i,j,currentTitle)=>{
this.hfInstance = hfInstance
if (callback) callback()
}
getCellValue = (i, j, currentTitle) => {
let hfInstance = this.props.hfInstance||this.hfInstance
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
}
if (hfInstance && currentTitle) {
let x = hfInstance.getCellValue({ col: j, row: i, sheet: hfInstance.getSheetId(currentTitle) })
if (x && x.value != null) {
x = x.value
}
return x;
}
}
componentWillReceiveProps(nextProps) {
componentWillReceiveProps(nextProps) {
const {
postData, // 数据源
isCg, // 用户点击草稿页面进入
isForm,
isPreview, // 是否为预览模式
isChild, // 是否为子表单
} = nextProps;
if (isPreview || isChild) {
......@@ -314,8 +392,10 @@ export default class ZdyTable extends Component {
...nextProps,
isReady: true,
formConfig: { ...this.state.formConfig, style: nextProps.style },
});
this.initExcel({datas:nextProps.datas,trees:nextProps.trees})
},()=>this.initExcel({ datas: nextProps.datas, trees: nextProps.trees }));
return;
}
......@@ -352,7 +432,7 @@ export default class ZdyTable extends Component {
isBorder: this.props.table ? obj.datas[val.formKey].isBorder : xxx.isBorder,
mapData,
currentFormKey: this.props.table ? val.formKey : obj.init,
currentFormTitle:this.getCurrentFormTitle(obj,fk),
currentFormTitle: this.getCurrentFormTitle(obj, fk),
sqlData,
isEdit: !this.props.formKey,
items: this.props.table ? obj.datas[val.formKey].items : xxx.items,
......@@ -360,7 +440,7 @@ export default class ZdyTable extends Component {
appId: val.appId,
isReady: true,
formConfig: xxx,
},()=> this.initExcel(obj));
}, () => this.initExcel(obj));
return;
}
if (isCg === 'yes') {
......@@ -391,7 +471,7 @@ export default class ZdyTable extends Component {
datas: obj.datas,
isEdit: !this.props.formKey,
currentFormKey: obj.init,
currentFormTitle:this.getCurrentFormTitle(obj,obj.init),
currentFormTitle: this.getCurrentFormTitle(obj, obj.init),
width: xxx.width,
isBorder: xxx.isBorder,
isRowCol: xxx.isRowCol,
......@@ -404,7 +484,7 @@ export default class ZdyTable extends Component {
defaultBinds: this.props.table
? obj.datas[val.taskFormKey].defaultBinds
: xxx.defaultBinds,
},()=> this.initExcel(obj));
}, () => this.initExcel(obj));
return;
}
const mapData = {};
......@@ -427,7 +507,7 @@ export default class ZdyTable extends Component {
}
const obj = JSON.parse(val.unifiedServicePatternModel.content);
const xxx = obj.datas[this.props.formKey ? this.props.formKey : obj.init]; // 是否是存在历史表单传入值
const fk=this.props.formKey
const fk = this.props.formKey
? this.props.formKey
: val.taskFormKey
? val.taskFormKey
......@@ -440,7 +520,7 @@ export default class ZdyTable extends Component {
defaultValues: val.unifiedServicePatternModel.defaultValues,
isEdit: !this.props.formKey,
currentFormKey: fk,
currentFormTitle:this.getCurrentFormTitle(obj,fk),
currentFormTitle: this.getCurrentFormTitle(obj, fk),
defaultBinds: this.props.table ? obj.datas[val.taskFormKey].defaultBinds : xxx.defaultBinds,
width: this.props.table ? obj.datas[val.taskFormKey].width : xxx.width,
isBorder: this.props.table ? obj.datas[val.taskFormKey].isBorder : xxx.isBorder,
......@@ -450,13 +530,13 @@ export default class ZdyTable extends Component {
init: { ...this.state.init, ...(val.isSecond ? this.props.obj : {}) },
formConfig: xxx,
// init:this.props.get==="mobile"?!!val.content?JSON.parse(val.content):'':{},// 移动端默认值设置
},()=> this.initExcel(obj));
}, () => this.initExcel(obj));
} catch (e) {
console.log('公式配置有误', e);
}
}
}
checkAllHidden = row => {
checkAllHidden = row => {
for (var i = 0; i < row.length; i++) {
if (row[i].hidden == null || !row[i].hidden) {
return false;
......@@ -466,9 +546,9 @@ export default class ZdyTable extends Component {
delete row[i].hidden;
}
return true;
};
};
countMax = items => {
countMax = items => {
let max = 0;
items.forEach(r => {
if (r.length > max) {
......@@ -476,17 +556,38 @@ export default class ZdyTable extends Component {
}
});
return max;
};
getCurrentFormTitle=(obj,key)=>{
};
getCurrentFormTitle = (obj, key) => {
if(obj==null) return
const { trees } = obj
if(trees==null) return
return this.getT(trees,key)
}
getCurrentFormTitle2 = ( key) => {
if(this.configs==null) return
const { trees } = this.configs
if(trees==null) return
return this.getT(trees,key)
}
getT=(trees,key)=>{
for (var i = 0; i < trees.length; i++) {
const {trees}=obj
for(var i=0;i<trees.length;i++){
if(trees[i].key==key){
if(trees[i].children==null||trees[i].children.length==0){
if (trees[i].key == key) {
return trees[i].title
}
}else{
return this.getT(trees[i].children,key)
}
}
render() {
}
render() {
const {
width,
......@@ -655,6 +756,7 @@ export default class ZdyTable extends Component {
return (
<tr key={i}>
{row.map((cell, j) => {
if (!cell.content) {
return;
}
......@@ -702,7 +804,10 @@ export default class ZdyTable extends Component {
}}
>
<TableCom
importExcel={this.importExcel}
getCellValue={this.getCellValue}
getCurrentFormTitle={this.getCurrentFormTitle2}
hfInstance={this.hfInstance}
isWebPrintEnd={isWebPrintEnd}
isWebPrint={isWebPrint}
isPrint={this.props.isPrint}
......@@ -807,8 +912,11 @@ export default class ZdyTable extends Component {
: ''}
<IsNewTable
getCellValue={this.getCellValue}
hfInstance={this.hfInstance}
getCurrentFormTitle={this.getCurrentFormTitle2}
taskAssignee={taskAssignee} // 提交人
userId={userId}
importExcel={this.importExcel}
isPreview={isPreview}
isRowCol={isRowCol}
modalInit={modalInit}
......@@ -839,55 +947,11 @@ export default class ZdyTable extends Component {
concealModel={concealModel || {}} // 场景设计器内置路由跳转函数
isDynamic={isDynamic} // 是否为场景配置器调用
/>
{/* {
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 || {}}
messageData={messageData} // 场景设计器共享变量参数
/></>
})
}
</div>)
})
} */}
</Form>
)}
</>
);
}
}
}
}
......@@ -39,7 +39,9 @@ export default class isNewTable extends Component {
concealModel,
taskAssignee,
currentFormTitle,
getCellValue
getCellValue,
hfInstance,
getCurrentFormTitle
} = this.props;
if (!isEdit) {
// 展示栏 暂不做处理
......@@ -91,6 +93,7 @@ export default class isNewTable extends Component {
i={i}
j={j}
index={index}
getCurrentFormTitle
fatherCode={fatherCode}
datas={datas}
isEdit={isEdit}
......@@ -98,6 +101,8 @@ export default class isNewTable extends Component {
formKey={currentFormKey}
currentFormTitle
getCellValue
hfInstance
initExcel={this.props.initExcel}
init={init}
get={get}
key={j}
......@@ -168,9 +173,12 @@ export default class isNewTable extends Component {
fatherCode={fatherCode}
datas={datas}
isEdit={isEdit}
getCurrentFormTitle
importExcel={this.props.importExcel}
fatherObj={this.props.fatherObj}
formKey={currentFormKey}
currentFormTitle
hfInstance
getCellValue
init={init}
get={get}
......@@ -214,9 +222,12 @@ export default class isNewTable extends Component {
datas={datas}
modalInit={modalInit}
isEdit={isEdit}
getCurrentFormTitle
fatherObj={this.props.fatherObj}
formKey={currentFormKey}
importExcel={this.props.importExcel}
currentFormTitle
hfInstance
getCellValue
init={init}
get={get}
......
......@@ -1144,6 +1144,7 @@ export default class tableCom extends Component {
moment: moment,
sql: this.sqlUtil.bind(this, base52, json, callback),
message: message,
importExcel:this.props.importExcel,
router: router,
uuid: UUID,
setValues: this.setValues.bind(this, base52, json),
......@@ -1483,12 +1484,16 @@ export default class tableCom extends Component {
if (formKey == fk) {
return <>片段表单key不能和自身相同</>;
}
return (
<>
{this.props.form.getFieldDecorator(this.props.uuid, {
initialValue: fk,
})(<Input type="hidden" />)}{' '}
<ZdyTable
hfInstance={this.props.hfInstance}
currentFormTitle={this.props.getCurrentFormTitle(fk)}
getCellValue={getCellValue}
taskAssignee={taskAssignee}
isWebPrint={this.props.isWebPrint || false}
userId={userId}
......@@ -2571,7 +2576,6 @@ export default class tableCom extends Component {
break;
case 'Select':
console.log();
cm = getFieldDecorator(dataColumn.base52, {
initialValue: initValue,
rules:
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论