提交 92b7c78c authored 作者: 钟是志's avatar 钟是志

一站式bug修改. this.initExcel 方法

可能存在其他问题 要喊欢哥确认
上级 d2568fef
......@@ -13,12 +13,13 @@ import { HyperFormula } from 'hyperformula';
import TableCom from '../tableCompon';
import IsNewTable from './isNewMobileTable';
import maintain from '../assets/maintain.png';
export default class ZdyTable extends Component {
constructor(props) {
super(props);
this.state = {
isChange:false,
isChange: false,
selects: new Map(),
left: 0,
top: 0,
......@@ -54,11 +55,14 @@ export default class ZdyTable extends Component {
} = this.props;
if (isPreview || isChild) {
this.initExcel({ datas: this.props.datas, trees: this.props.trees },()=>this.setState({ ...this.state,
this.initExcel({ datas: this.props.datas, trees: this.props.trees }, () => {
this.setState(
{
...this.state,
...this.props,
formConfig: { ...this.state.formConfig, style: this.props.style }, isReady: true,}));
formConfig: { ...this.state.formConfig, style: this.props.style }, isReady: true,
});
});
return;
}
......@@ -203,7 +207,7 @@ export default class ZdyTable extends Component {
? this.props.formKey
: val.taskFormKey
? val.taskFormKey
: obj.init
: obj.init;
this.setState(
{
appId: val.id,
......@@ -235,7 +239,7 @@ export default class ZdyTable extends Component {
if (isQRCode) {
this.props.form.setFieldsValue(formDeafault);
}
this.initExcel(obj)
this.initExcel(obj);
},
);
} catch (e) {
......@@ -243,15 +247,16 @@ export default class ZdyTable extends Component {
}
}
importExcel = (res) => {
const{datas,trees} = this.configs
const sheets = res.sheets
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
const items = [];
const cc = sheets[s].cells;
for (var i = 0; i < cc.length; i++) {
const rows = [];
const rr = cc[i];
......@@ -297,7 +302,7 @@ export default class ZdyTable extends Component {
}
}
if(datas[uuid]==null){
if (datas[uuid] == null) {
trees.push({ title: sheets[s].name, key: uuid });
}
datas[uuid] = {
......@@ -308,74 +313,78 @@ export default class ZdyTable extends Component {
};
}
this.initExcel({ datas, trees },()=>this.setState({isChange:!this.state.isChange}))
console.log("公式导入excel成功")
this.initExcel({ datas, trees }, () => this.setState({ isChange: !this.state.isChange }));
console.log('公式导入excel成功');
}
};
hfInstance;
childExcel = (sheetData, datas, tr) => {
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])
this.childExcel(sheetData, datas, tr.children[c]);
}
}
const data = datas[tr.key]
const all = []
const data = datas[tr.key];
const all = [];
for (var i = 0; i < data.items.length; i++) {
const row = data.items[i]
const r = []
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)
const col = row[j];
if (col.content?.comName == 'Excel') {
r.push(col.content.initialValue);
} else {
r.push('')
r.push('');
}
}
all.push(r)
all.push(r);
}
sheetData[tr.title] = all
sheetData[tr.title] = all;
}
configs
initExcel = (configs, callback) => {
};
configs;
initExcel = (configs, callback) => {
if (configs == null || configs.trees == null) return
if (configs == null || configs.trees == null){
if (callback) callback();
return ;
}
if(configs.trees!=null) this.configs=configs
if (configs.trees != null) this.configs = configs;
const sheetData = {}
const sheetData = {};
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) => {
let hfInstance = this.props.hfInstance?this.props.hfInstance:this.hfInstance
this.hfInstance = hfInstance;
if (callback) callback();
};
getCellValue = (i, j, currentTitle) => {
let hfInstance = this.props.hfInstance ? this.props.hfInstance : this.hfInstance;
if (hfInstance && currentTitle) {
let x = hfInstance.getCellValue({ col: j, row: i, sheet: hfInstance.getSheetId(currentTitle) })
let x = hfInstance.getCellValue({ col: j, row: i, sheet: hfInstance.getSheetId(currentTitle) });
if (x && x.value != null) {
x = x.value
x = x.value;
}
return x;
}
}
componentWillReceiveProps(nextProps) {
};
componentWillReceiveProps(nextProps) {
const {
postData, // 数据源
isCg, // 用户点击草稿页面进入
......@@ -391,10 +400,7 @@ componentWillReceiveProps(nextProps) {
...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;
}
......@@ -510,7 +516,7 @@ componentWillReceiveProps(nextProps) {
? this.props.formKey
: val.taskFormKey
? val.taskFormKey
: obj.init
: obj.init;
this.setState({
appId: val.id,
datas: obj.datas,
......@@ -533,9 +539,9 @@ componentWillReceiveProps(nextProps) {
} 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;
......@@ -545,9 +551,9 @@ checkAllHidden = row => {
delete row[i].hidden;
}
return true;
};
};
countMax = items => {
countMax = items => {
let max = 0;
items.forEach(r => {
if (r.length > max) {
......@@ -555,38 +561,38 @@ countMax = items => {
}
});
return max;
};
getCurrentFormTitle = (obj, key) => {
};
getCurrentFormTitle = (obj, key) => {
if(obj==null) return
const { trees } = obj
if(trees==null) return
return this.getT(trees,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)
};
getCurrentFormTitle2 = (key) => {
if (this.configs == null) return;
const { trees } = this.configs;
if (trees == null) return;
return this.getT(trees, key);
}
getT=(trees,key)=>{
};
getT = (trees, key) => {
for (var i = 0; i < trees.length; i++) {
if(trees[i].children==null||trees[i].children.length==0){
if (trees[i].children == null || trees[i].children.length == 0) {
if (trees[i].key == key) {
return trees[i].title
return trees[i].title;
}
}else{
} else {
return this.getT(trees[i].children,key)
return this.getT(trees[i].children, key);
}
}
}
};
render() {
render() {
const {
width,
......@@ -625,7 +631,7 @@ render() {
isDynamic, // 是否为大数据页面
isWebPrint, // 打印界面
isWebPrintEnd,
isPreview
isPreview,
} = this.props;
let style = {};
if (formConfig.style != null) {
......@@ -674,6 +680,10 @@ render() {
width: '100%',
paddingBottom: paddingBottom != null ? paddingBottom : isWebPrint ? 0 : '10px',
};
if (currentFormKey) {
console.log(currentFormKey);
}
if (!isReady) return <></>;
if (this.props.postData?.isUpdate) {
updateTime = moment(+this.props.postData?.updateTime).format('llll');
......@@ -726,7 +736,7 @@ render() {
return this.props.form.getFieldDecorator(name, {
initialValue: value,
})(<Input type="hidden" />);
})(<Input type="hidden"/>);
})
: ''}
......@@ -906,7 +916,7 @@ render() {
return this.props.form.getFieldDecorator(name, {
initialValue: value,
})(<Input type="hidden" />);
})(<Input type="hidden"/>);
})
: ''}
<IsNewTable
......@@ -952,5 +962,5 @@ render() {
</>
);
}
}
}
}
......@@ -81,7 +81,9 @@ class StandardTable extends Component {
showQuickJumper: true,
...pagination,
};
if(typeof paginationProps.total === 'string'){
paginationProps.total = Number(paginationProps.total) || 0;
}
const rowSelection = {
selectedRowKeys,
onChange: this.handleRowSelectChange,
......@@ -116,7 +118,13 @@ class StandardTable extends Component {
loading={loading}
rowKey={rowKey || 'key'}
rowSelection={typeof noSelectRow !== 'undefined' && noSelectRow ? null : rowSelection}
dataSource={list}
dataSource={list.map((x) => {
return {
id: Math.random() * 10000 + '',
...x,
}
})}
bordered={bordered}
columns={columns}
size="small"
......
......@@ -3,13 +3,7 @@ import {Button, Form, Input, InputNumber, Modal, Select} from "antd";
export default class FormModal extends React.Component {
render() {
return (
<Modal
destroyOnClose
......@@ -26,4 +20,3 @@ export default class FormModal extends React.Component {
);
}
}
\ No newline at end of file
......@@ -1471,7 +1471,6 @@ export default class tableCom extends Component {
return <></>;
return <QRCode {...this.state.option} key={this.props.uuid} />;
}
if (json.comName == 'Echart') {
return (
<ReactEcharts
......@@ -1503,7 +1502,6 @@ export default class tableCom extends Component {
if (formKey == fk) {
return <>片段表单key不能和自身相同</>;
}
return (
<>
{this.props.form.getFieldDecorator(this.props.uuid, {
......@@ -3124,6 +3122,7 @@ export default class tableCom extends Component {
);
}
if (get === 'web') {
if (!isEdit) {
return (
<Row
......@@ -3200,6 +3199,7 @@ export default class tableCom extends Component {
</Row>
);
} else {
return (
<>
{modalCode ? (
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论