From eb164d66b57fbc93a04415de4afce82f30f3e49f Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期一, 06 三月 2023 09:21:20 +0800
Subject: [PATCH] 2023-03-06

---
 src/views/menudesign/printmenuform/index.jsx |  168 +++++++++++++++++++++++++++++++++++++++++++++++---------
 1 files changed, 141 insertions(+), 27 deletions(-)

diff --git a/src/views/menudesign/printmenuform/index.jsx b/src/views/menudesign/printmenuform/index.jsx
index a6de29a..be3c97d 100644
--- a/src/views/menudesign/printmenuform/index.jsx
+++ b/src/views/menudesign/printmenuform/index.jsx
@@ -1,21 +1,14 @@
 import React, {Component} from 'react'
 import PropTypes from 'prop-types'
-import { Form, Row, Col, InputNumber, Select, Radio } from 'antd'
+import { Form, Row, Col, InputNumber, Select, Radio, Tooltip } from 'antd'
+import { QuestionCircleOutlined } from '@ant-design/icons'
 
-import './index.scss'
+// 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) => {
@@ -25,27 +18,91 @@
     this.props.updateConfig({...this.props.config, everyPCount: val})
   }
 
-  changeLastCount = (val) => {
+  changePrintWidth = (val) => {
     if (typeof(val) !== 'number') {
       val = ''
     }
-    this.props.updateConfig({...this.props.config, lastCount: val})
+    this.props.updateConfig({...this.props.config, printWidth: val})
+  }
+
+  changePrintHeight = (val) => {
+    if (typeof(val) !== 'number') {
+      val = ''
+    }
+    this.props.updateConfig({...this.props.config, printHeight: val})
+  }
+
+  onPrintPageChange = (val) => {
+    this.props.updateConfig({...this.props.config, printPage: val})
   }
 
   pageSizeChange = (val) => {
     this.props.updateConfig({...this.props.config, pageSize: val})
+    this.resetPage()
   }
 
   onLayoutChange = (val) => {
     this.props.updateConfig({...this.props.config, pageLayout: val})
+    this.resetPage()
   }
   
   onPaddingChange = (val) => {
     this.props.updateConfig({...this.props.config, pagePadding: val})
+    this.resetPage()
+  }
+
+  onPrintCustomChange = (val) => {
+    this.props.updateConfig({...this.props.config, printCustom: val})
+    this.resetPage()
+  }
+
+  resetPage = () => {
+    this.setState({}, () => {
+      const { config } = this.props
+  
+      if (config.printCustom !== 'true') return
+  
+      let pageSize = config.pageSize || 'A4'
+      let pageLayout = config.pageLayout !== 'horizontal' ? 'vertical' : 'horizontal'
+      let pagePadding = config.pagePadding !== 'without' ? 'default' : 'without'
+  
+      let pageParam = {
+        A4: {
+          vertical: 980,
+          horizontal: 1200,
+          verticaldefault: 1.455,
+          verticalwithout: 1.411,
+          horizontaldefault: 0.679,
+          horizontalwithout: 0.701,
+        },
+        A3: {
+          vertical: 1200,
+          horizontal: 1600,
+          verticaldefault: 1.441,
+          verticalwithout: 1.410,
+          horizontaldefault: 0.688,
+          horizontalwithout: 0.703,
+        },
+        A5: {
+          vertical: 700,
+          horizontal: 1000,
+          verticaldefault: 1.478,
+          verticalwithout: 1.413,
+          horizontaldefault: 0.669,
+          horizontalwithout: 0.700,
+        }
+      }
+  
+      let width = pageParam[pageSize][pageLayout]
+      let height = Math.floor(width * pageParam[pageSize][pageLayout + pagePadding])
+  
+      this.props.updateConfig({...config, printHeight: height, printWidth: width})
+      this.props.form.setFieldsValue({printHeight: height, printWidth: width})
+    })
   }
 
   render() {
-    const { dict, config } = this.props
+    const { config } = this.props
     const { getFieldDecorator } = this.props.form
     const formItemLayout = {
       labelCol: {
@@ -59,8 +116,22 @@
     }
 
     return (
-      <Form {...formItemLayout} className="print-menu-form">
+      <Form {...formItemLayout}>
         <Row>
+          <Col span={24}>
+            <Form.Item label="鑿滃崟鍚嶇О">
+              <span style={{display: 'inline-block', wordBreak: 'break-all', lineHeight: 1.5}}>
+                {config.MenuName}
+              </span>
+            </Form.Item>
+          </Col>
+          <Col span={24}>
+            <Form.Item label="鑿滃崟鍙傛暟">
+              <span style={{display: 'inline-block', wordBreak: 'break-all', lineHeight: 1.5}}>
+                {config.MenuNo}
+              </span>
+            </Form.Item>
+          </Col>
           <Col span={24}>
             <Form.Item label="鎵撳嵃灏哄">
               {getFieldDecorator('pageSize', {
@@ -68,7 +139,7 @@
                 rules: [
                   {
                     required: true,
-                    message: dict['mob.required.input'] + '鎵撳嵃灏哄!'
+                    message: '璇烽�夋嫨鎵撳嵃灏哄!'
                   }
                 ]
               })(
@@ -87,7 +158,7 @@
                 rules: [
                   {
                     required: true,
-                    message: dict['mob.required.select'] + '鎵撳嵃甯冨眬!'
+                    message: '璇烽�夋嫨鎵撳嵃甯冨眬!'
                   }
                 ]
               })(
@@ -105,7 +176,7 @@
                 rules: [
                   {
                     required: true,
-                    message: dict['mob.required.select'] + '鎵撳嵃杈硅窛!'
+                    message: '璇烽�夋嫨鎵撳嵃杈硅窛!'
                   }
                 ]
               })(
@@ -117,38 +188,81 @@
             </Form.Item>
           </Col>
           <Col span={24}>
+            <Form.Item label="椤甸潰甯冨眬">
+              {getFieldDecorator('printPage', {
+                initialValue: config.printPage || 'auto'
+              })(
+                <Radio.Group onChange={(e) => {this.onPrintPageChange(e.target.value)}}>
+                  <Radio value="auto">鑷�傚簲</Radio>
+                  <Radio value="page">鍒嗛〉</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'] + '棣栭〉鏁�!'
+                    message: '璇疯緭鍏ラ椤垫暟!'
                   }
                 ]
-              })(<InputNumber min={1} max={1000} precision={0} onChange={this.changeFirstCount}/>)}
+              })(<InputNumber min={1} max={1000} precision={1} onChange={this.changeFirstCount}/>)}
             </Form.Item>
-          </Col>
-          <Col span={24}>
+          </Col> */}
+          {config.printPage === 'page' ? <Col span={24}>
             <Form.Item label="姣忛〉鏁�(鏉�)">
               {getFieldDecorator('everyPCount', {
-                initialValue: config.everyPCount,
+                initialValue: config.everyPCount || 15,
                 rules: [
                   {
                     required: true,
-                    message: dict['mob.required.input'] + '姣忛〉鏁�!'
+                    message: '璇疯緭鍏ユ瘡椤垫暟!'
                   }
                 ]
-              })(<InputNumber min={1} max={1000} precision={0} onChange={this.changeCount}/>)}
+              })(<InputNumber min={1} max={1000} precision={1} onChange={this.changeCount}/>)}
             </Form.Item>
-          </Col>
-          <Col span={24}>
+          </Col> : null}
+          {/* <Col span={24}>
             <Form.Item label="灏鹃〉鏁�(鏉�)">
               {getFieldDecorator('lastCount', {
                 initialValue: config.lastCount
-              })(<InputNumber min={1} max={1000} precision={0} onChange={this.changeLastCount}/>)}
+              })(<InputNumber min={1} max={1000} precision={1} onChange={this.changeLastCount}/>)}
+            </Form.Item>
+          </Col> */}
+          <Col span={24}>
+            <Form.Item label={
+              <Tooltip placement="topLeft" title="閽堝涓嶈鍒欑焊寮狅紝鍙嚜瀹氫箟璁剧疆鎵撳嵃楂樺害鍜屽搴︼紝娉細鍚屾椂璁剧疆鎵撳嵃瀹藉害鍜岄珮搴﹀悗鏂瑰彲鐢熸晥銆�">
+                <QuestionCircleOutlined className="mk-form-tip" />
+                鑷畾涔�
+              </Tooltip>
+            }>
+              {getFieldDecorator('printCustom', {
+                initialValue: config.printCustom || 'false'
+              })(
+                <Radio.Group onChange={(e) => {this.onPrintCustomChange(e.target.value)}}>
+                  <Radio value="false">涓嶅惎鐢�</Radio>
+                  <Radio value="true">鍚敤</Radio>
+                </Radio.Group>
+              )}
             </Form.Item>
           </Col>
+          {config.printCustom === 'true' ? <Col span={24}>
+            <Form.Item label="鎵撳嵃瀹藉害">
+              {getFieldDecorator('printWidth', {
+                initialValue: config.printWidth || ''
+              })(<InputNumber min={10} max={9999} precision={0} onChange={this.changePrintWidth}/>)}
+            </Form.Item>
+          </Col> : null}
+          {config.printCustom === 'true' ? <Col span={24}>
+            <Form.Item label="鎵撳嵃楂樺害">
+              {getFieldDecorator('printHeight', {
+                initialValue: config.printHeight || ''
+              })(<InputNumber min={10} max={9999} precision={0} onChange={this.changePrintHeight}/>)}
+            </Form.Item>
+          </Col> : null}
         </Row>
       </Form>
     )

--
Gitblit v1.8.0