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

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

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