gm-printer 10.11.5 → 10.13.1-alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/.eslintcache CHANGED
@@ -1 +1 @@
1
- [{"/Users/yancheng/gm/gm-open-source/gm-printer/src/printer/table.js":"1","/Users/yancheng/gm/gm-open-source/gm-printer/src/printer/store.js":"2","/Users/yancheng/gm/gm-open-source/gm-printer/src/editor/editor.js":"3","/Users/yancheng/gm/gm-open-source/gm-printer/src/editor/context_menu.js":"4","/Users/yancheng/gm/gm-open-source/gm-printer/src/components/tooltip/index.js":"5","/Users/yancheng/gm/gm-open-source/gm-printer/src/common/common_context_menu.js":"6","/Users/yancheng/gm/gm-open-source/gm-printer/src/util.js":"7","/Users/yancheng/gm/gm-open-source/gm-printer/src/printer/printer.js":"8"},{"size":8814,"mtime":1633276961204,"results":"9","hashOfConfig":"10"},{"size":11105,"mtime":1632648482981,"results":"11","hashOfConfig":"10"},{"size":4066,"mtime":1621236648877,"results":"12","hashOfConfig":"10"},{"size":3192,"mtime":1621238473815,"results":"13","hashOfConfig":"10"},{"size":616,"mtime":1621235314060,"results":"14","hashOfConfig":"10"},{"size":9693,"mtime":1621242097206,"results":"15","hashOfConfig":"10"},{"size":5968,"mtime":1632644668974,"results":"16","hashOfConfig":"10"},{"size":8724,"mtime":1631266134763,"results":"17","hashOfConfig":"10"},{"filePath":"18","messages":"19","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},"175njjo",{"filePath":"20","messages":"21","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"22","messages":"23","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"24","messages":"25","errorCount":17,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"source":null},{"filePath":"26","messages":"27","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"28","messages":"29","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"30","messages":"31","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"32","messages":"33","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},"/Users/yancheng/gm/gm-open-source/gm-printer/src/printer/table.js",[],"/Users/yancheng/gm/gm-open-source/gm-printer/src/printer/store.js",[],"/Users/yancheng/gm/gm-open-source/gm-printer/src/editor/editor.js",[],"/Users/yancheng/gm/gm-open-source/gm-printer/src/editor/context_menu.js",["34","35","36","37","38","39","40","41","42","43","44","45","46","47","48","49","50"],"/Users/yancheng/gm/gm-open-source/gm-printer/src/components/tooltip/index.js",[],"/Users/yancheng/gm/gm-open-source/gm-printer/src/common/common_context_menu.js",[],"/Users/yancheng/gm/gm-open-source/gm-printer/src/util.js",[],"/Users/yancheng/gm/gm-open-source/gm-printer/src/printer/printer.js",[],{"ruleId":"51","severity":2,"message":"52","line":7,"column":10,"nodeType":"53","endLine":7,"endColumn":38},{"ruleId":"54","severity":2,"message":"55","line":38,"column":34,"nodeType":"53","endLine":38,"endColumn":43},{"ruleId":"54","severity":2,"message":"56","line":38,"column":44,"nodeType":"53","endLine":38,"endColumn":50},{"ruleId":"54","severity":2,"message":"57","line":38,"column":51,"nodeType":"53","endLine":38,"endColumn":59},{"ruleId":"54","severity":2,"message":"55","line":44,"column":13,"nodeType":"58","endLine":44,"endColumn":22},{"ruleId":"54","severity":2,"message":"59","line":46,"column":15,"nodeType":"53","endLine":46,"endColumn":33},{"ruleId":"54","severity":2,"message":"55","line":50,"column":13,"nodeType":"58","endLine":50,"endColumn":22},{"ruleId":"54","severity":2,"message":"60","line":52,"column":15,"nodeType":"53","endLine":52,"endColumn":30},{"ruleId":"54","severity":2,"message":"55","line":62,"column":46,"nodeType":"53","endLine":62,"endColumn":55},{"ruleId":"54","severity":2,"message":"56","line":62,"column":56,"nodeType":"53","endLine":62,"endColumn":62},{"ruleId":"54","severity":2,"message":"57","line":62,"column":63,"nodeType":"53","endLine":62,"endColumn":71},{"ruleId":"54","severity":2,"message":"55","line":94,"column":13,"nodeType":"58","endLine":94,"endColumn":22},{"ruleId":"54","severity":2,"message":"61","line":94,"column":24,"nodeType":"58","endLine":94,"endColumn":32},{"ruleId":"54","severity":2,"message":"62","line":101,"column":26,"nodeType":"53","endLine":101,"endColumn":44},{"ruleId":"54","severity":2,"message":"63","line":102,"column":31,"nodeType":"53","endLine":102,"endColumn":39},{"ruleId":"54","severity":2,"message":"64","line":103,"column":37,"nodeType":"53","endLine":103,"endColumn":51},{"ruleId":"54","severity":2,"message":"56","line":104,"column":29,"nodeType":"53","endLine":104,"endColumn":35},"no-unused-vars","'noSubtotalBtnTableDataKeySet' is defined but never used.","Identifier","react/prop-types","'editStore' is missing in props validation","'editStore.config' is missing in props validation","'editStore.config.contents' is missing in props validation","Property","'editStore.changeTableDataKey' is missing in props validation","'editStore.setSubtotalShow' is missing in props validation","'mockData' is missing in props validation","'editStore.computedPrinterKey' is missing in props validation","'editStore.selected' is missing in props validation","'editStore.selectedRegion' is missing in props validation"]
1
+ [{"/Users/yancheng/gm/gm-open-source/gm-printer/src/printer/table.js":"1","/Users/yancheng/gm/gm-open-source/gm-printer/src/printer/store.js":"2","/Users/yancheng/gm/gm-open-source/gm-printer/src/editor/editor.js":"3","/Users/yancheng/gm/gm-open-source/gm-printer/src/editor/context_menu.js":"4","/Users/yancheng/gm/gm-open-source/gm-printer/src/components/tooltip/index.js":"5","/Users/yancheng/gm/gm-open-source/gm-printer/src/common/common_context_menu.js":"6","/Users/yancheng/gm/gm-open-source/gm-printer/src/util.js":"7","/Users/yancheng/gm/gm-open-source/gm-printer/src/printer/printer.js":"8","/Users/yancheng/gm/gm-open-source/gm-printer/src/printer/store copy.js":"9","/Users/yancheng/gm/gm-open-source/gm-printer/src/printer/do_print.js":"10","/Users/yancheng/gm/gm-open-source/gm-printer/src/common/editor_special_field.js":"11"},{"size":8814,"mtime":1633276961204,"results":"12","hashOfConfig":"13"},{"size":11087,"mtime":1634195458602,"results":"14","hashOfConfig":"15"},{"size":4066,"mtime":1621236648877,"results":"16","hashOfConfig":"13"},{"size":3192,"mtime":1621238473815,"results":"17","hashOfConfig":"13"},{"size":616,"mtime":1621235314060,"results":"18","hashOfConfig":"13"},{"size":9693,"mtime":1621242097206,"results":"19","hashOfConfig":"13"},{"size":5968,"mtime":1634191487398,"results":"20","hashOfConfig":"15"},{"size":8724,"mtime":1631266134763,"results":"21","hashOfConfig":"13"},{"size":11087,"mtime":1634191487394,"results":"22","hashOfConfig":"15"},{"size":3119,"mtime":1634191808754,"results":"23","hashOfConfig":"15"},{"size":1186,"mtime":1634193250064,"results":"24","hashOfConfig":"15"},{"filePath":"25","messages":"26","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},"175njjo",{"filePath":"27","messages":"28","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},"1j0d8vf",{"filePath":"29","messages":"30","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"31","messages":"32","errorCount":17,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"source":null},{"filePath":"33","messages":"34","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"35","messages":"36","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"37","messages":"38","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"39","messages":"40","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"41","messages":"42","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"43","messages":"44","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"45","messages":"46","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},"/Users/yancheng/gm/gm-open-source/gm-printer/src/printer/table.js",[],"/Users/yancheng/gm/gm-open-source/gm-printer/src/printer/store.js",[],"/Users/yancheng/gm/gm-open-source/gm-printer/src/editor/editor.js",[],"/Users/yancheng/gm/gm-open-source/gm-printer/src/editor/context_menu.js",["47","48","49","50","51","52","53","54","55","56","57","58","59","60","61","62","63"],"/Users/yancheng/gm/gm-open-source/gm-printer/src/components/tooltip/index.js",[],"/Users/yancheng/gm/gm-open-source/gm-printer/src/common/common_context_menu.js",[],"/Users/yancheng/gm/gm-open-source/gm-printer/src/util.js",[],"/Users/yancheng/gm/gm-open-source/gm-printer/src/printer/printer.js",[],"/Users/yancheng/gm/gm-open-source/gm-printer/src/printer/store copy.js",[],"/Users/yancheng/gm/gm-open-source/gm-printer/src/printer/do_print.js",[],"/Users/yancheng/gm/gm-open-source/gm-printer/src/common/editor_special_field.js",[],{"ruleId":"64","severity":2,"message":"65","line":7,"column":10,"nodeType":"66","endLine":7,"endColumn":38},{"ruleId":"67","severity":2,"message":"68","line":38,"column":34,"nodeType":"66","endLine":38,"endColumn":43},{"ruleId":"67","severity":2,"message":"69","line":38,"column":44,"nodeType":"66","endLine":38,"endColumn":50},{"ruleId":"67","severity":2,"message":"70","line":38,"column":51,"nodeType":"66","endLine":38,"endColumn":59},{"ruleId":"67","severity":2,"message":"68","line":44,"column":13,"nodeType":"71","endLine":44,"endColumn":22},{"ruleId":"67","severity":2,"message":"72","line":46,"column":15,"nodeType":"66","endLine":46,"endColumn":33},{"ruleId":"67","severity":2,"message":"68","line":50,"column":13,"nodeType":"71","endLine":50,"endColumn":22},{"ruleId":"67","severity":2,"message":"73","line":52,"column":15,"nodeType":"66","endLine":52,"endColumn":30},{"ruleId":"67","severity":2,"message":"68","line":62,"column":46,"nodeType":"66","endLine":62,"endColumn":55},{"ruleId":"67","severity":2,"message":"69","line":62,"column":56,"nodeType":"66","endLine":62,"endColumn":62},{"ruleId":"67","severity":2,"message":"70","line":62,"column":63,"nodeType":"66","endLine":62,"endColumn":71},{"ruleId":"67","severity":2,"message":"68","line":94,"column":13,"nodeType":"71","endLine":94,"endColumn":22},{"ruleId":"67","severity":2,"message":"74","line":94,"column":24,"nodeType":"71","endLine":94,"endColumn":32},{"ruleId":"67","severity":2,"message":"75","line":101,"column":26,"nodeType":"66","endLine":101,"endColumn":44},{"ruleId":"67","severity":2,"message":"76","line":102,"column":31,"nodeType":"66","endLine":102,"endColumn":39},{"ruleId":"67","severity":2,"message":"77","line":103,"column":37,"nodeType":"66","endLine":103,"endColumn":51},{"ruleId":"67","severity":2,"message":"69","line":104,"column":29,"nodeType":"66","endLine":104,"endColumn":35},"no-unused-vars","'noSubtotalBtnTableDataKeySet' is defined but never used.","Identifier","react/prop-types","'editStore' is missing in props validation","'editStore.config' is missing in props validation","'editStore.config.contents' is missing in props validation","Property","'editStore.changeTableDataKey' is missing in props validation","'editStore.setSubtotalShow' is missing in props validation","'mockData' is missing in props validation","'editStore.computedPrinterKey' is missing in props validation","'editStore.selected' is missing in props validation","'editStore.selectedRegion' is missing in props validation"]
package/locales/en.json CHANGED
@@ -16,6 +16,7 @@
16
16
  "粗细": "",
17
17
  "高": "",
18
18
  "图片大小不能超过500Kb": "",
19
+ "配送单特殊控制": "",
19
20
  "添加字段": "",
20
21
  "编辑字段": "",
21
22
  "请输入填充内容": "",
package/locales/th.json CHANGED
@@ -16,6 +16,7 @@
16
16
  "粗细": "",
17
17
  "高": "",
18
18
  "图片大小不能超过500Kb": "",
19
+ "配送单特殊控制": "",
19
20
  "添加字段": "",
20
21
  "编辑字段": "",
21
22
  "请输入填充内容": "",
@@ -18,6 +18,7 @@
18
18
  "图片大小不能超过500Kb": "圖片大小不能超過500Kb",
19
19
  "添加字段": "添加字段",
20
20
  "编辑字段": "編輯字段",
21
+ "配送单特殊控制": "配送单特殊控制",
21
22
  "请输入填充内容": "請輸入填充內容",
22
23
  "请输入链接": "請輸入鏈接",
23
24
  "说明:谨慎修改{}中的内容,避免出现数据异常": "説明:請勿修改{}中的內容,避免出現數據異常",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gm-printer",
3
- "version": "10.11.5",
3
+ "version": "10.13.1-alpha.1",
4
4
  "description": "diy printer",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
@@ -602,6 +602,37 @@ Title.propTypes = {
602
602
  text: PropTypes.object
603
603
  }
604
604
 
605
+ const Radio = ({ id, value, radioChecked, checked }) => (
606
+ <div>
607
+ <input
608
+ type='radio'
609
+ value={value}
610
+ id={id}
611
+ name='radio'
612
+ onChange={radioChecked}
613
+ checked={checked}
614
+ style={{ margin: '5px 10px 0 0' }}
615
+ />
616
+ <label htmlFor={id}>{value}</label>
617
+ <Gap />
618
+ </div>
619
+ )
620
+
621
+ Radio.propTypes = {
622
+ id: PropTypes.string,
623
+ value: PropTypes.string,
624
+ radioChecked: PropTypes.func,
625
+ checked: PropTypes.string
626
+ }
627
+
628
+ const RadioGap = ({ width = '100%', height = '15px' }) => (
629
+ <div style={{ width, height }} />
630
+ )
631
+ RadioGap.propTypes = {
632
+ width: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
633
+ height: PropTypes.oneOfType([PropTypes.string, PropTypes.number])
634
+ }
635
+
605
636
  const Gap = ({ width = '100%', height = '3px' }) => (
606
637
  <div style={{ width, height }} />
607
638
  )
@@ -649,7 +680,9 @@ export {
649
680
  Hr,
650
681
  SubTitle,
651
682
  Title,
683
+ Radio,
652
684
  Gap,
685
+ RadioGap,
653
686
  FieldBtn,
654
687
  TipInfo
655
688
  }
@@ -0,0 +1,43 @@
1
+ import i18next from '../../locales'
2
+ import React from 'react'
3
+ import PropTypes from 'prop-types'
4
+ import { Gap, RadioGap, Title, Radio } from './component'
5
+ import { observer, inject } from 'mobx-react'
6
+
7
+ @inject('editStore')
8
+ @observer
9
+ class SpecialField extends React.Component {
10
+ render() {
11
+ const { addFields, mockData, editStore } = this.props
12
+ const specialFields = addFields.specialFields
13
+ const tableData = mockData?._table
14
+
15
+ return (
16
+ <div>
17
+ <Title title={i18next.t('配送单特殊控制')} />
18
+ <RadioGap />
19
+ {specialFields &&
20
+ specialFields.map(fields => (
21
+ <Radio
22
+ id={fields.id}
23
+ value={fields.value}
24
+ key={fields.id}
25
+ checked={editStore.config.specialConfig === fields.id}
26
+ radioChecked={() => editStore.radioChecked(fields, tableData)}
27
+ />
28
+ ))}
29
+ <Gap />
30
+ </div>
31
+ )
32
+ }
33
+ }
34
+
35
+ SpecialField.propTypes = {
36
+ fields: PropTypes.object.isRequired,
37
+ handleAddField: PropTypes.func,
38
+ addFields: PropTypes.object.isRequired,
39
+ editStore: PropTypes.object,
40
+ mockData: PropTypes.object.isRequired
41
+ }
42
+
43
+ export default SpecialField
@@ -550,6 +550,11 @@ class EditorStore {
550
550
  }
551
551
  }
552
552
 
553
+ @action.bound
554
+ radioChecked(fields) {
555
+ this.config.specialConfig = fields.id
556
+ }
557
+
553
558
  @action
554
559
  removeField() {
555
560
  if (!this.selected) {
@@ -7,6 +7,7 @@ import editStore from './store'
7
7
  import { observer, inject } from 'mobx-react'
8
8
  import EditorTitle from '../common/editor_title'
9
9
  import EditorSelect from '../common/editor_select'
10
+ import SpecialField from '../common/editor_special_field'
10
11
  import EditorField from '../common/editor_edit_field'
11
12
  import EditorAddField from '../common/editor_add_field'
12
13
  import EditorPageSummary from '../common/editor_page_summary'
@@ -38,7 +39,7 @@ export const noSubtotalBtnTableDataKeySet = new Set(
38
39
  @observer
39
40
  class Editor extends React.Component {
40
41
  render() {
41
- const { onSave, showEditor, addFields, showNewDate } = this.props
42
+ const { onSave, showEditor, addFields, showNewDate, mockData } = this.props
42
43
 
43
44
  return (
44
45
  <div className='gm-printer-edit'>
@@ -75,12 +76,14 @@ class Editor extends React.Component {
75
76
  <Gap height='10px' />
76
77
  <EditorSelect />
77
78
  <Gap height='5px' />
79
+ <SpecialField addFields={addFields} mockData={mockData} />
80
+ <Gap height='5px' />
78
81
  <EditorField
79
82
  tableDataKeyList={tableDataKeyList}
80
83
  showNewDate={showNewDate}
81
84
  />
82
85
  <Gap height='5px' />
83
- <EditorAddField addFields={addFields} />
86
+ <EditorAddField addFields={addFields} mockData={mockData} />
84
87
  <Gap height='5px' />
85
88
  <EditorPageSummary summaryFields={addFields.summaryFields} />
86
89
 
package/src/index.js CHANGED
@@ -10,7 +10,14 @@ import EditorAccoutStatement from './editor_account_statement'
10
10
  import EditorBoxLabel from './editor_box_label'
11
11
  import EditorSaleMenus from './editor_salemenus'
12
12
  import EditorAccount from './editor_account'
13
- import { BatchPrinter, doBatchPrint, doPrint, Printer, getCSS } from './printer'
13
+ import {
14
+ BatchPrinter,
15
+ doBatchPrint,
16
+ doPrint,
17
+ Printer,
18
+ getCSS,
19
+ getPrintContainerHTML
20
+ } from './printer'
14
21
  import { MULTI_SUFFIX } from './config'
15
22
 
16
23
  export * from './util'
@@ -32,5 +39,6 @@ export {
32
39
  doPrint,
33
40
  doBatchPrint,
34
41
  getCSS,
35
- MULTI_SUFFIX
42
+ MULTI_SUFFIX,
43
+ getPrintContainerHTML
36
44
  }
@@ -8,9 +8,13 @@ import { afterImgAndSvgLoaded } from '../util'
8
8
 
9
9
  const printerId = '_gm-printer_' + Math.random()
10
10
  let $printer = window.document.getElementById(printerId)
11
-
12
- function init(isTest) {
13
- isZoom() &&
11
+ /**
12
+ * @param {boolean} isTest 是否test
13
+ * @param {boolean} isTipZoom zoom的时候是否提示
14
+ */
15
+ function init({ isTest, isTipZoom = true } = {}) {
16
+ isTipZoom &&
17
+ isZoom() &&
14
18
  window.alert(
15
19
  '检测您的浏览器使用了缩放,为了避免影响打印布局,请重置缩放到100%后再进行打印'
16
20
  )
@@ -68,7 +72,7 @@ function toDoPrint({ data, config }) {
68
72
  })
69
73
  }
70
74
 
71
- function toDoPrintBatch(list) {
75
+ function toDoPrintBatch(list, isPrint = true) {
72
76
  return new window.Promise(resolve => {
73
77
  const $app = $printer.contentWindow.document.getElementById('appContainer')
74
78
 
@@ -78,7 +82,7 @@ function toDoPrintBatch(list) {
78
82
  list={list}
79
83
  onReady={() => {
80
84
  afterImgAndSvgLoaded(() => {
81
- $printer.contentWindow.print()
85
+ isPrint && $printer.contentWindow.print()
82
86
  resolve()
83
87
  }, $app)
84
88
  }}
@@ -89,15 +93,32 @@ function toDoPrintBatch(list) {
89
93
  }
90
94
 
91
95
  function doPrint({ data, config }, isTest) {
92
- init(isTest)
96
+ init({ isTest })
93
97
 
94
98
  return toDoPrint({ data, config })
95
99
  }
96
100
 
97
- function doBatchPrint(list, isTest) {
98
- init(isTest)
101
+ // function doBatchPrint(list, isTest, { isPrint, isTipZoom }) {
102
+ // init({ isTest, isTipZoom })
103
+
104
+ // return toDoPrintBatch(list, isPrint)
105
+ // }
99
106
 
100
- return toDoPrintBatch(list)
107
+ function doBatchPrint(
108
+ list,
109
+ isTest,
110
+ extraCofnig = { isPrint: true, isTipZoom: true }
111
+ ) {
112
+ init({ isTest, isTipZoom: extraCofnig.isTipZoom })
113
+
114
+ return toDoPrintBatch(list, extraCofnig.isPrint)
101
115
  }
102
116
 
103
- export { doPrint, doBatchPrint }
117
+ /**
118
+ * @description: 获取打印的html
119
+ */
120
+ function getPrintContainerHTML() {
121
+ return $printer.contentWindow.document.getElementsByTagName('html')[0]
122
+ .innerHTML
123
+ }
124
+ export { doPrint, doBatchPrint, getPrintContainerHTML }
@@ -1,6 +1,13 @@
1
1
  import Printer from './printer'
2
2
  import BatchPrinter from './batch_printer'
3
- import { doPrint, doBatchPrint } from './do_print'
3
+ import { doPrint, doBatchPrint, getPrintContainerHTML } from './do_print'
4
4
  import getCSS from './get_css'
5
5
 
6
- export { doPrint, doBatchPrint, Printer, BatchPrinter, getCSS }
6
+ export {
7
+ doPrint,
8
+ doBatchPrint,
9
+ Printer,
10
+ BatchPrinter,
11
+ getCSS,
12
+ getPrintContainerHTML
13
+ }