From 7facbed508592e842f9bca085cf0ffaebcbfc571 Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期四, 12 十一月 2020 19:22:37 +0800 Subject: [PATCH] 2020-11-12 --- src/tabviews/custom/components/card/table-card/index.jsx | 5 src/views/menudesign/menuform/index.scss | 0 src/tabviews/custom/components/card/prop-card/index.jsx | 12 + src/tabviews/custom/components/chart/antv-bar-line/index.jsx | 5 src/views/menudesign/printmenuform/index.scss | 5 src/tabviews/custom/components/chart/antv-pie/index.jsx | 5 src/views/menudesign/menuform/index.jsx | 5 src/views/menudesign/printmenuform/index.jsx | 139 +++++++++++++++++++ src/views/billprint/index.scss | 4 src/templates/zshare/createinterface/index.jsx | 4 src/views/billprint/index.jsx | 196 +++++++++++++++++++++++++--- src/menu/components/card/data-card/wrapsetting/settingform/index.jsx | 17 ++ src/views/menudesign/index.jsx | 11 + src/menu/datasource/verifycard/index.jsx | 6 src/tabviews/custom/components/card/data-card/index.jsx | 5 15 files changed, 382 insertions(+), 37 deletions(-) diff --git a/src/menu/components/card/data-card/wrapsetting/settingform/index.jsx b/src/menu/components/card/data-card/wrapsetting/settingform/index.jsx index 54cc70f..67fcd12 100644 --- a/src/menu/components/card/data-card/wrapsetting/settingform/index.jsx +++ b/src/menu/components/card/data-card/wrapsetting/settingform/index.jsx @@ -172,6 +172,23 @@ })(<InputNumber min={100} max={2000} precision={0} onPressEnter={this.handleSubmit} />)} </Form.Item> </Col> : null} + {MenuType === 'billPrint' && config.subtype === 'propcard' ? <Col span={12}> + <Form.Item label={ + <Tooltip placement="topLeft" title="閫夋嫨绫诲瀷涓恒�婇〉鐪�/椤佃剼銆嬫椂锛屾墦鍗扮殑姣忛〉閲岄兘浼氬甫鏈夎缁勪欢銆�"> + <Icon type="question-circle" /> + 缁勪欢绫诲瀷 + </Tooltip> + }> + {getFieldDecorator('printType', { + initialValue: wrap.printType || 'content' + })( + <Radio.Group> + <Radio value="content">鍐呭</Radio> + <Radio value="headerOrfooter">椤电湁/椤佃剼</Radio> + </Radio.Group> + )} + </Form.Item> + </Col> : null} {MenuType !== 'billPrint' ? <Col span={12}> <Form.Item label="榛戝悕鍗�"> {getFieldDecorator('blacklist', { diff --git a/src/menu/datasource/verifycard/index.jsx b/src/menu/datasource/verifycard/index.jsx index b26eef2..96f6126 100644 --- a/src/menu/datasource/verifycard/index.jsx +++ b/src/menu/datasource/verifycard/index.jsx @@ -177,9 +177,9 @@ let _setting = fromJS(config.setting).toJS() - if (!_setting.varMark) { - _setting.varMark = this.getMark(Marks) - } + // if (!_setting.varMark) { + // _setting.varMark = this.getMark(Marks) + // } this.setState({ columns: fromJS(config.columns).toJS(), diff --git a/src/tabviews/custom/components/card/data-card/index.jsx b/src/tabviews/custom/components/card/data-card/index.jsx index 712d50a..81112d1 100644 --- a/src/tabviews/custom/components/card/data-card/index.jsx +++ b/src/tabviews/custom/components/card/data-card/index.jsx @@ -35,7 +35,7 @@ } UNSAFE_componentWillMount () { - const { data } = this.props + const { data, initdata } = this.props let _config = fromJS(this.props.config).toJS() let _card = _config.subcards[0] let _cols = new Map() @@ -46,6 +46,9 @@ if (_config.setting.sync === 'true' && data) { _data = data[_config.dataName] || [] _sync = false + } else if (_config.setting.sync === 'true' && initdata) { + _data = initdata || [] + _sync = false } _config.columns.forEach(item => { diff --git a/src/tabviews/custom/components/card/prop-card/index.jsx b/src/tabviews/custom/components/card/prop-card/index.jsx index eb10b83..7987e98 100644 --- a/src/tabviews/custom/components/card/prop-card/index.jsx +++ b/src/tabviews/custom/components/card/prop-card/index.jsx @@ -30,7 +30,7 @@ } UNSAFE_componentWillMount () { - const { data } = this.props + const { data, initdata } = this.props let _config = fromJS(this.props.config).toJS() let _cols = new Map() @@ -39,15 +39,21 @@ if (_config.setting && _config.wrap.datatype !== 'static') { _sync = _config.setting.sync === 'true' - if (_config.setting.sync === 'true' && data) { + if (_sync && data) { _data = data[_config.dataName] + if (_data && Array.isArray(_data)) { + _data = _data[0] + } + _sync = false + } else if (_sync && initdata) { + _data = initdata if (_data && Array.isArray(_data)) { _data = _data[0] } _sync = false } } else { - _data = [] + _data = {} } _config.columns.forEach(item => { diff --git a/src/tabviews/custom/components/card/table-card/index.jsx b/src/tabviews/custom/components/card/table-card/index.jsx index b0bae18..63a2e77 100644 --- a/src/tabviews/custom/components/card/table-card/index.jsx +++ b/src/tabviews/custom/components/card/table-card/index.jsx @@ -34,7 +34,7 @@ } UNSAFE_componentWillMount () { - const { data } = this.props + const { data, initdata } = this.props let _config = fromJS(this.props.config).toJS() let _cols = new Map() @@ -44,6 +44,9 @@ if (_config.setting.sync === 'true' && data) { _data = data[_config.dataName] || [] _sync = false + } else if (_config.setting.sync === 'true' && initdata) { + _data = initdata || [] + _sync = false } let showHeader = false diff --git a/src/tabviews/custom/components/chart/antv-bar-line/index.jsx b/src/tabviews/custom/components/chart/antv-bar-line/index.jsx index e249816..6347ffb 100644 --- a/src/tabviews/custom/components/chart/antv-bar-line/index.jsx +++ b/src/tabviews/custom/components/chart/antv-bar-line/index.jsx @@ -45,7 +45,7 @@ } UNSAFE_componentWillMount () { - const { config, data } = this.props + const { config, data, initdata } = this.props let _config = fromJS(config).toJS() let _data = null @@ -54,6 +54,9 @@ if (config.setting.sync === 'true' && data) { _data = data[config.dataName] || [] _sync = false + } else if (config.setting.sync === 'true' && initdata) { + _data = initdata || [] + _sync = false } let vFields = [] diff --git a/src/tabviews/custom/components/chart/antv-pie/index.jsx b/src/tabviews/custom/components/chart/antv-pie/index.jsx index 1b755b4..447101a 100644 --- a/src/tabviews/custom/components/chart/antv-pie/index.jsx +++ b/src/tabviews/custom/components/chart/antv-pie/index.jsx @@ -35,7 +35,7 @@ } UNSAFE_componentWillMount () { - const { config, data } = this.props + const { config, data, initdata } = this.props let _config = fromJS(config).toJS() let _data = null @@ -44,6 +44,9 @@ if (config.setting.sync === 'true' && data) { _data = data[config.dataName] || [] _sync = false + } else if (config.setting.sync === 'true' && initdata) { + _data = initdata || [] + _sync = false } let showHeader = false diff --git a/src/templates/zshare/createinterface/index.jsx b/src/templates/zshare/createinterface/index.jsx index 3bc051f..1583cd2 100644 --- a/src/templates/zshare/createinterface/index.jsx +++ b/src/templates/zshare/createinterface/index.jsx @@ -966,7 +966,7 @@ if (item.writein === false) return keys.push(item.key.toLowerCase()) - values.push('@' + item.key + '@') + values.push('@' + item.key) }) if (!keys.includes(primaryKey.toLowerCase())) { @@ -1006,7 +1006,7 @@ if (item.writein === false) return _arr.push(item.key.toLowerCase()) - _form.push(item.key + `=@${item.key}@`) + _form.push(item.key + `=@${item.key}`) }) if (!_arr.includes('modifydate')) { diff --git a/src/views/billprint/index.jsx b/src/views/billprint/index.jsx index 9565445..57d0ea1 100644 --- a/src/views/billprint/index.jsx +++ b/src/views/billprint/index.jsx @@ -25,6 +25,7 @@ dict: localStorage.getItem('lang') !== 'en-US' ? zhCN : enUS, loadingview: true, dataManager: false, + pages: null, BID: '', data: '', tempId: '', @@ -105,6 +106,48 @@ return } + config.style = config.style || {} + + if (config.pageSize === 'A0') { + if (config.pageLayout === 'horizontal') { + config.style.height = 1305 + } else { + config.style.height = 1305 + } + } else if (config.pageSize === 'A1') { + if (config.pageLayout === 'horizontal') { + config.style.height = 1305 + } else { + config.style.height = 1305 + } + } else if (config.pageSize === 'A2') { + if (config.pageLayout === 'horizontal') { + config.style.height = 1305 + } else { + config.style.height = 1305 + } + } else if (config.pageSize === 'A3') { + if (config.pageLayout === 'horizontal') { + config.style.height = 1305 + } else { + config.style.height = 1305 + } + } else if (config.pageSize === 'A5') { + if (config.pageLayout === 'horizontal') { + config.style.height = 1305 + } else { + config.style.height = 1305 + } + } else { + if (config.pageLayout === 'horizontal') { + config.style.height = 895 + } else { + config.style.height = 1305 + } + } + + // config.style.height = 895 + let params = [] let _pars = [] @@ -112,6 +155,7 @@ config.components = config.components.map(component => { if (component.action) component.action = [] if (component.search) component.search = [] + component.data = [] // 鍒濆鍖栨暟鎹负绌� if (!component.setting) return component // 涓嶄娇鐢ㄧ郴缁熷嚱鏁版椂 if (!component.format || (component.subtype === 'propcard' && component.wrap.datatype === 'static')) return component // 娌℃湁鍔ㄦ�佹暟鎹� 鏁版嵁鏍煎紡 array 鎴� object @@ -186,7 +230,7 @@ config }, () => { if (params.length === 0) { - this.setState({loadingview: false}) + this.setState({loadingview: false, pages: [config.components]}) } else { this.loadmaindata(params) } @@ -272,6 +316,8 @@ * @description 涓昏〃鏁版嵁鍔犺浇 */ loadmaindata = (params) => { + const { components, everyPCount, firstCount, lastCount } = this.state.config + let deffers = params.map(item => { let componentId = item.componentId delete item.componentId @@ -295,16 +341,124 @@ Promise.all(deffers).then(results => { let _results = results.filter(Boolean) - this.setState({loadingview: false}) + let comps = components.map(item => { + if (item.subtype === 'propcard' && item.wrap.datatype === 'static') return item - if (_results.length === results.length) { - console.log(_results) + _results.forEach(res => { + if (res.componentId === item.uuid && res.data) { + item.data = res.data + item.dataArray = fromJS(res.data).toJS() + } else if (res.componentId === 'union' && res[item.dataName]) { + item.data = res[item.dataName] + item.dataArray = fromJS(res[item.dataName]).toJS() + } + }) + + return item + }) + + let length = comps.length + let pageIndex = 1 + let pages = [] + let over = false + + if (length === 0) { + this.setState({loadingview: false, pages}) } - // delete result.ErrCode - // delete result.ErrMesg - // delete result.message - // delete result.status + // everyPCount, firstCount, lastCount + while (!over) { + let page = [] + let count = 0 + let _pageover = false + let pagesover = false + + let limit = pageIndex === 1 ? (firstCount || 20) : (everyPCount || 20) + + comps.forEach((_item, index) => { + let item = fromJS(_item).toJS() + if (item.wrap && item.wrap.printType === 'headerOrfooter') { // 椤电湁椤佃剼 + page.push(item) + } else if (_pageover) { + return + } else if (item.type === 'card' && item.subtype === 'datacard') { + if (!_item.dataArray || _item.dataArray.length === 0) return + + item.data = [] + + while (count < limit && _item.dataArray.length > 0) { + item.data.push(_item.dataArray.shift()) + count++ + } + + if (count >= limit) { + _pageover = true + } + page.push(item) + } else { + page.push(item) + } + + if (index + 1 === length && !_pageover) { + pagesover = true + } + }) + + if (pagesover && lastCount && count > lastCount) { + pagesover = false + page = [] + count = 0 + _pageover = false + + if (pageIndex === 1) { + limit = (everyPCount - firstCount) + (everyPCount - lastCount) + + if (limit <= 0) { + limit = firstCount + } + } else { + limit = lastCount + } + + comps.forEach((_item, index) => { + let item = fromJS(_item).toJS() + if (item.wrap && item.wrap.printType === 'headerOrfooter') { // 椤电湁椤佃剼 + page.push(item) + } else if (_pageover) { + return + } else if (item.type === 'card' && item.subtype === 'datacard') { + if (!_item.dataArray || _item.dataArray.length === 0) return + + item.data = [] + + while (count < limit && _item.dataArray.length > 0) { + item.data.push(_item.dataArray.shift()) + count++ + } + + if (count >= limit) { + _pageover = true + } + page.push(item) + } else { + page.push(item) + } + + if (index + 1 === length && !_pageover) { + pagesover = true + } + }) + } + + pages.push(page) + pageIndex++ + + if (pageIndex >= 2000 || pagesover) { + over = true + } + } + + this.setState({loadingview: false, pages}) }) } @@ -312,7 +466,7 @@ let bdhtml = window.document.body.innerHTML let jubuData = document.getElementById('bill-print').innerHTML window.document.body.innerHTML = jubuData - // document.getElementsByTagName('body')[0].style.zoom = 0.7 + document.getElementsByTagName('body')[0].style.zoom = 0.8 try { if (window.ActiveXObject) { @@ -366,34 +520,32 @@ window.location.reload() } - getComponents = () => { - const { config, BID, data, dataManager } = this.state + getComponents = (components) => { + const { dataManager } = this.state - return config.components.map(item => { - if (!item) return null - + return components.map(item => { if (item.type === 'bar' || item.type === 'line') { return ( <Col span={item.width} key={item.uuid}> - <AntvBarAndLine config={item} data={data} BID={BID} mainSearch={[]} menuType="" dataManager={dataManager} /> + <AntvBarAndLine config={item} initdata={item.data} mainSearch={[]} menuType="" dataManager={dataManager} /> </Col> ) } else if (item.type === 'pie') { return ( <Col span={item.width} key={item.uuid}> - <AntvPie config={item} data={data} BID={BID} mainSearch={[]} menuType="" dataManager={dataManager} /> + <AntvPie config={item} initdata={item.data} mainSearch={[]} menuType="" dataManager={dataManager} /> </Col> ) } else if (item.type === 'card' && item.subtype === 'datacard') { return ( <Col span={item.width} key={item.uuid}> - <DataCard config={item} data={data} BID={BID} mainSearch={[]} menuType="" dataManager={dataManager} /> + <DataCard config={item} initdata={item.data} mainSearch={[]} menuType="" dataManager={dataManager} /> </Col> ) } else if (item.type === 'card' && item.subtype === 'propcard') { return ( <Col span={item.width} key={item.uuid}> - <PropCard config={item} data={data} BID={BID} mainSearch={[]} menuType="" dataManager={dataManager} /> + <PropCard config={item} initdata={item.data} mainSearch={[]} menuType="" dataManager={dataManager} /> </Col> ) } else { @@ -403,14 +555,16 @@ } render() { - const { loadingview, viewlost, config } = this.state + const { loadingview, viewlost, config, pages } = this.state return ( <div className="bill-print-wrap" > {loadingview && <Spin size="large" />} - {config ? <div id="bill-print" style={config.style}><Row>{this.getComponents()}</Row></div> : null} + {pages ? <div id="bill-print"> + {pages.map((components, index) => (<div className="print-page" key={index} style={config.style}><Row>{this.getComponents(components)}</Row></div>))} + </div> : null} {viewlost ? <NotFount msg={this.state.lostmsg} /> : null} - {!loadingview && !viewlost ? <div className="print-button"><Button onClick={this.print}>鎵撳嵃</Button></div> : null} + {pages && !loadingview && !viewlost ? <div className="print-button"><Button icon="printer" size="large" shape="circle" onClick={this.print}></Button></div> : null} </div> ) } diff --git a/src/views/billprint/index.scss b/src/views/billprint/index.scss index a42978b..aed46a2 100644 --- a/src/views/billprint/index.scss +++ b/src/views/billprint/index.scss @@ -11,6 +11,10 @@ .box404 { margin-top: 10vh; } + .print-page { + height: 900px; + overflow: hidden; + } .print-button { position: fixed; right: 10px; diff --git a/src/views/menudesign/index.jsx b/src/views/menudesign/index.jsx index 360391f..4cf1e23 100644 --- a/src/views/menudesign/index.jsx +++ b/src/views/menudesign/index.jsx @@ -22,8 +22,9 @@ const { confirm } = Modal const _locale = localStorage.getItem('lang') !== 'en-US' ? antdZhCN : antdEnUS +const MenuForm = asyncComponent(() => import('./menuform')) +const PrintMenuForm = asyncComponent(() => import('./printmenuform')) const Header = asyncComponent(() => import('@/menu/header')) -const MenuForm = asyncComponent(() => import('@/menu/menuform')) const SourceWrap = asyncComponent(() => import('@/menu/modelsource')) const MenuShell = asyncComponent(() => import('@/menu/menushell')) const BgController = asyncComponent(() => import('@/menu/bgcontroller')) @@ -296,6 +297,9 @@ config.FstID = 'BillPrintTemp' config.SndID = 'BillPrintTemp' config.ParentID = 'BillPrintTemp' + config.firstCount = config.firstCount || 5 + config.everyPCount = config.everyPCount || 5 + config.lastCount = config.lastCount || '' } this.setState({ @@ -467,6 +471,11 @@ initMenuList={this.initMenuList} updateConfig={this.updateConfig} /> : null} + {config && MenuType === 'billPrint' ? <PrintMenuForm + dict={dict} + config={config} + updateConfig={this.updateConfig} + /> : null} {/* 琛ㄥ悕娣诲姞 */} {config ? <TableComponent config={config} updatetable={this.updatetable}/> : null} </Panel> diff --git a/src/menu/menuform/index.jsx b/src/views/menudesign/menuform/index.jsx similarity index 97% rename from src/menu/menuform/index.jsx rename to src/views/menudesign/menuform/index.jsx index a0fe3e8..8c4594c 100644 --- a/src/menu/menuform/index.jsx +++ b/src/views/menudesign/menuform/index.jsx @@ -4,10 +4,9 @@ import { Form, Row, Col, Input, Select, notification } from 'antd' import Api from '@/api' -// import { formRule } from '@/utils/option.js' import './index.scss' -class MainSearch extends Component { +class CustomMenuForm extends Component { static propTpyes = { dict: PropTypes.object, // 瀛楀吀椤� config: PropTypes.object, @@ -226,4 +225,4 @@ } } -export default Form.create()(MainSearch) \ No newline at end of file +export default Form.create()(CustomMenuForm) \ No newline at end of file diff --git a/src/menu/menuform/index.scss b/src/views/menudesign/menuform/index.scss similarity index 100% rename from src/menu/menuform/index.scss rename to src/views/menudesign/menuform/index.scss diff --git a/src/views/menudesign/printmenuform/index.jsx b/src/views/menudesign/printmenuform/index.jsx new file mode 100644 index 0000000..11debb7 --- /dev/null +++ b/src/views/menudesign/printmenuform/index.jsx @@ -0,0 +1,139 @@ +import React, {Component} from 'react' +import PropTypes from 'prop-types' +import { Form, Row, Col, InputNumber, Select, Radio } from 'antd' + +import './index.scss' + +class MainSearch extends Component { + static propTpyes = { + dict: PropTypes.object, // 瀛楀吀椤� + config: PropTypes.object, + updateConfig: PropTypes.func + } + + changeFirstCount = (val) => { + if (typeof(val) !== 'number') { + val = '' + } + this.props.updateConfig({...this.props.config, firstCount: val}) + } + + changeCount = (val) => { + if (typeof(val) !== 'number') { + val = '' + } + this.props.updateConfig({...this.props.config, everyPCount: val}) + } + + changeLastCount = (val) => { + if (typeof(val) !== 'number') { + val = '' + } + this.props.updateConfig({...this.props.config, lastCount: val}) + } + + pageSizeChange = (val) => { + this.props.updateConfig({...this.props.config, pageSize: val}) + } + + onRadioChange = (val) => { + this.props.updateConfig({...this.props.config, pageLayout: val}) + } + + render() { + const { dict, config } = this.props + const { getFieldDecorator } = this.props.form + const formItemLayout = { + labelCol: { + xs: { span: 24 }, + sm: { span: 8 } + }, + wrapperCol: { + xs: { span: 24 }, + sm: { span: 16 } + } + } + + return ( + <Form {...formItemLayout} className="print-menu-form"> + <Row> + <Col span={24}> + <Form.Item label="鎵撳嵃灏哄"> + {getFieldDecorator('pageSize', { + initialValue: config.pageSize || 'A4', + rules: [ + { + required: true, + message: dict['mob.required.input'] + '鎵撳嵃灏哄!' + } + ] + })( + <Select onChange={this.pageSizeChange}> + <Select.Option value="A0">A0</Select.Option> + <Select.Option value="A1">A1</Select.Option> + <Select.Option value="A2">A2</Select.Option> + <Select.Option value="A3">A3</Select.Option> + <Select.Option value="A4">A4</Select.Option> + <Select.Option value="A5">A5</Select.Option> + </Select> + )} + </Form.Item> + </Col> + <Col span={24}> + <Form.Item label="鎵撳嵃甯冨眬"> + {getFieldDecorator('pageLayout', { + initialValue: config.pageLayout || 'vertical', + rules: [ + { + required: true, + message: dict['mob.required.input'] + '鎵撳嵃甯冨眬!' + } + ] + })( + <Radio.Group onChange={(e) => {this.onRadioChange(e.target.value)}}> + <Radio value="vertical">绾靛悜</Radio> + <Radio value="horizontal">妯悜</Radio> + </Radio.Group> + )} + </Form.Item> + </Col> + <Col span={24}> + <Form.Item label="棣栭〉鏁�(鏉�)"> + {getFieldDecorator('firstCount', { + initialValue: config.firstCount, + rules: [ + { + required: true, + message: dict['mob.required.input'] + '棣栭〉鏁�!' + } + ] + })(<InputNumber min={1} max={1000} precision={0} onChange={this.changeFirstCount}/>)} + </Form.Item> + </Col> + <Col span={24}> + <Form.Item label="姣忛〉鏁�(鏉�)"> + {getFieldDecorator('everyPCount', { + initialValue: config.everyPCount, + rules: [ + { + required: true, + message: dict['mob.required.input'] + '姣忛〉鏁�!' + } + ] + })(<InputNumber min={1} max={1000} precision={0} onChange={this.changeCount}/>)} + </Form.Item> + </Col> + <Col span={24}> + <Form.Item label="灏鹃〉鏁�(鏉�)"> + {getFieldDecorator('lastCount', { + initialValue: config.lastCount + })(<InputNumber min={1} max={1000} precision={0} onChange={this.changeLastCount}/>)} + </Form.Item> + </Col> + </Row> + </Form> + ) + } +} + +export default Form.create()(MainSearch) \ No newline at end of file diff --git a/src/views/menudesign/printmenuform/index.scss b/src/views/menudesign/printmenuform/index.scss new file mode 100644 index 0000000..0c9f8a8 --- /dev/null +++ b/src/views/menudesign/printmenuform/index.scss @@ -0,0 +1,5 @@ +.print-menu-form { + .ant-input-number { + width: 100%; + } +} \ No newline at end of file -- Gitblit v1.8.0