gm-printer 10.11.5-beta2 → 10.11.5

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.
Files changed (40) hide show
  1. package/.eslintcache +1 -1
  2. package/README.md +102 -7
  3. package/build/demo.js +54 -0
  4. package/locales/en.json +1 -0
  5. package/locales/th.json +1 -0
  6. package/locales/zh-HK.json +1 -0
  7. package/package.json +10 -8
  8. package/src/common/editor_edit_field.js +82 -16
  9. package/src/common/editor_store.js +58 -0
  10. package/src/components/index.js +3 -1
  11. package/src/components/index.less +1 -0
  12. package/src/components/tip/index.js +19 -35
  13. package/src/components/tooltip/index.js +26 -0
  14. package/src/components/tooltip/style.less +16 -0
  15. package/src/editor/context_menu.js +16 -16
  16. package/src/editor/editor.js +16 -9
  17. package/src/editor/store.js +97 -12
  18. package/src/{editor_cannibalize → editor_account}/context_menu.js +42 -16
  19. package/src/{editor_cannibalize → editor_account}/editor.js +24 -9
  20. package/src/editor_account/index.js +4 -0
  21. package/src/editor_account/store.js +263 -0
  22. package/src/editor_purchase/context_menu.js +0 -1
  23. package/src/editor_purchase/editor_special_table.js +5 -2
  24. package/src/editor_purchase/store.js +27 -5
  25. package/src/index.js +2 -2
  26. package/src/printer/block.js +18 -10
  27. package/src/printer/printer.js +2 -2
  28. package/src/printer/qrcode.js +5 -2
  29. package/src/printer/store.js +116 -30
  30. package/src/printer/style.lesss +13 -3
  31. package/src/printer/table.js +57 -16
  32. package/src/printer/table_special_tr.js +1 -0
  33. package/src/printer/table_subtotal_tr.js +47 -7
  34. package/src/svg/question-circle-o.svg +1 -0
  35. package/src/util.js +53 -2
  36. package/webpack.config.js +19 -1
  37. package/global.d.ts +0 -67
  38. package/src/editor_cannibalize/index.js +0 -4
  39. package/src/editor_cannibalize/store.js +0 -29
  40. package/yarn-error.log +0 -9770
@@ -0,0 +1 @@
1
+ <?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg t="1564738751745" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="7454" xmlns:xlink="http://www.w3.org/1999/xlink" width="200" height="200"><defs><style type="text/css"></style></defs><path d="M512 814.3143524m-53.85930309 0a1.68310322 1.68310322 0 1 0 107.71860618 0 1.68310322 1.68310322 0 1 0-107.71860618 0ZM512 1011.40349551C234.8041201 1011.40349551 9.31317116 785.91254657 9.31317116 508.71666666S234.8041201 6.02983783 512 6.02983783s502.68682884 225.49094893 502.68682884 502.68682883S789.1958799 1011.40349551 512 1011.40349551zM512 78.16539777C274.58819198 78.16539777 81.4487311 271.30485865 81.4487311 508.71666666c0 237.37590183 193.13946088 430.5512689 430.5512689 430.55126891 237.37590183 0 430.5512689-193.17536708 430.5512689-430.55126891C942.5512689 271.30485865 749.37590183 78.16539777 512 78.16539777zM512 690.15070568c-19.82022354 0-35.90620206-16.08597852-35.90620206-35.90620206l0-60.7173877c0-58.74254656 44.88275257-103.62529915 84.52319965-143.22984C589.66511506 421.21325225 619.71860618 391.19566733 619.71860618 367.24623056c0-59.85563884-48.32974798-108.54444883-107.71860618-108.54444883-60.39423187 0-107.71860618 46.60625028-107.71860618 106.10282708 0 19.82022354-16.08597852 35.90620206-35.90620206 35.90620205s-35.90620206-16.08597852-35.90620207-35.90620205c0-98.09574403 80.53761122-177.91523121 179.53101031-177.91523121s179.53101031 80.89667324 179.53101031 180.35685296c0 53.75158448-40.75353933 94.46921762-80.14264301 133.85832126C580.14997152 532.27113522 547.90620206 564.51490466 547.90620206 593.49120973l0 60.71738769C547.90620206 674.02882095 531.82022354 690.15070568 512 690.15070568z" p-id="7455"></path></svg>
package/src/util.js CHANGED
@@ -15,7 +15,7 @@ function getHeight(el) {
15
15
 
16
16
  function getWidth(el) {
17
17
  const styles = window.getComputedStyle(el)
18
- const width = el.offsetWidth
18
+ const width = Math.ceil(el.offsetWidth)
19
19
  const borderLeftWidth = parseFloat(styles.borderLeftWidth)
20
20
  const borderRightWidth = parseFloat(styles.borderRightWidth)
21
21
  const paddingLeft = parseFloat(styles.paddingLeft)
@@ -178,6 +178,56 @@ const getDataKey = (dataKey, arrange) =>
178
178
  ? `${dataKey}_vertical`
179
179
  : dataKey
180
180
 
181
+ /**
182
+ * @param {*} table 当前单据的高度信息
183
+ * @param {*} detailsData 当前所有tablelist
184
+ * @param {*} currentPageMinimumHeight 当前page最小高度
185
+ * @param {*} pageHeight page的高度
186
+ * @returns {ranges, detailsPageHeight} detailsPageHeight 每页高度合集
187
+ */
188
+ const caclSingleDetailsPageHeight = (
189
+ indexEnd,
190
+ table,
191
+ detailsData,
192
+ heightParams
193
+ ) => {
194
+ let end = 0
195
+ let begin = 0
196
+ let index = 0
197
+ let currentDetailsMiniHeight = 0
198
+ const ranges = []
199
+ const detailsPageHeight = []
200
+ const { calcHeight, pageHeight, currentPageMinimumHeight } = heightParams
201
+
202
+ while (end < detailsData.length) {
203
+ currentDetailsMiniHeight += table.body.children[end]
204
+
205
+ const _calcHeight = !index && indexEnd === 0 ? calcHeight : pageHeight
206
+ // 如果当前明细高度综合大于页面高度,到此为止进行分页
207
+ if (currentDetailsMiniHeight + currentPageMinimumHeight > _calcHeight) {
208
+ detailsPageHeight.push(
209
+ currentDetailsMiniHeight - table.body.children[end]
210
+ )
211
+ ranges.push([begin, end])
212
+ end++
213
+ index++
214
+ begin = end
215
+ currentDetailsMiniHeight = 0
216
+ } else {
217
+ end++
218
+ if (end === detailsData.length) {
219
+ ranges.push([begin, end])
220
+ detailsPageHeight.push(currentDetailsMiniHeight)
221
+ }
222
+ }
223
+ }
224
+
225
+ return {
226
+ ranges,
227
+ detailsPageHeight
228
+ }
229
+ }
230
+
181
231
  export {
182
232
  getHeight,
183
233
  getWidth,
@@ -193,5 +243,6 @@ export {
193
243
  coverDigit2Uppercase,
194
244
  getDataKey,
195
245
  isMultiTable,
196
- getMultiNumber
246
+ getMultiNumber,
247
+ caclSingleDetailsPageHeight
197
248
  }
package/webpack.config.js CHANGED
@@ -36,6 +36,24 @@ module.exports = {
36
36
  }
37
37
  }
38
38
  ]
39
+ },
40
+ {
41
+ test: /\/svg\/(\w|\W)+\.svg$/,
42
+ use: [
43
+ {
44
+ loader: '@svgr/webpack',
45
+ options: {
46
+ icon: true,
47
+ expandProps: 'start',
48
+ svgProps: {
49
+ fill: 'currentColor',
50
+ // className 冗余
51
+ className:
52
+ "{'gm-svg-icon t-svg-icon m-svg-icon ' + (props.className || '')}"
53
+ }
54
+ }
55
+ }
56
+ ]
39
57
  }
40
58
  ]
41
59
  },
@@ -45,7 +63,7 @@ module.exports = {
45
63
  devServer: {
46
64
  compress: true,
47
65
  host: '0.0.0.0',
48
- port: 8081,
66
+ port: 5678,
49
67
  inline: false,
50
68
  disableHostCheck: true,
51
69
  proxy: {
package/global.d.ts DELETED
@@ -1,67 +0,0 @@
1
- declare module 'gm-printer' {
2
- import { CSSProperties } from 'react'
3
- interface EditorProps {
4
- config: any
5
- mockData: any
6
- onSave: (config: any, isSaveAs?: boolean) => void
7
- showEditor: boolean
8
- addFields: any
9
- }
10
- interface PrinterProps {
11
- data: any
12
- config: any
13
- className?: string
14
- style?: CSSProperties
15
- selected?: string
16
- selectedRegion?: string
17
- onReady?: () => void
18
- }
19
- interface BatchPrinterProps {
20
- list: any[]
21
- onReady?: () => void
22
- }
23
- // function Editor<P extends EditorProps>(props: P): React.ComponentType<P>
24
- class Editor<T extends EditorProps> extends React.Component<T, any> {}
25
- class EditorStockIn<T extends EditorProps> extends React.Component<T, any> {}
26
- class EditorStockOut<T extends EditorProps> extends React.Component<T, any> {}
27
- class EditorPurchase<T extends EditorProps> extends React.Component<T, any> {}
28
- class EditorSettle<T extends EditorProps> extends React.Component<T, any> {}
29
- class EditorCannibalize<T extends EditorProps> extends React.Component<T, any> {}
30
- class EditorStatement<T extends EditorProps> extends React.Component<
31
- T,
32
- any
33
- > {}
34
- class EditorAccoutStatement<T extends EditorProps> extends React.Component<
35
- T,
36
- any
37
- > {}
38
- class EditorBoxLabel<T extends EditorProps> extends React.Component<T, any> {}
39
- class Printer<T extends PrinterProps> extends React.Component<T, any> {}
40
- class BatchPrinter<T extends BatchPrinterProps> extends React.Component<T, any> {}
41
- const MULTI_SUFFIX: string
42
- function getCSS(): string
43
- function insertCSS(cssString: string, target?: HTMLElement | ShadowRoot): void
44
- function doPrint(
45
- obj: { data: any; config: any },
46
- isTest?: boolean
47
- ): (obj: { data: any; config: any }) => Promise<any>
48
- function doBatchPrint(list: any [], isTest?: boolean): (list: []) => Promise<any>
49
- export {
50
- Editor,
51
- EditorStockIn,
52
- EditorStockOut,
53
- EditorPurchase,
54
- EditorSettle,
55
- EditorCannibalize,
56
- EditorStatement,
57
- EditorAccoutStatement,
58
- EditorBoxLabel,
59
- Printer,
60
- BatchPrinter,
61
- MULTI_SUFFIX,
62
- insertCSS,
63
- getCSS,
64
- doPrint,
65
- doBatchPrint
66
- }
67
- }
@@ -1,4 +0,0 @@
1
- import withShadowDom from '../common/hoc_with_shadow_dom'
2
- import Editor from './editor'
3
-
4
- export default withShadowDom(Editor)
@@ -1,29 +0,0 @@
1
- import EditorStore from '../common/editor_store'
2
- import { action } from 'mobx'
3
- import _ from 'lodash'
4
-
5
- class Store extends EditorStore {
6
- @action
7
- changeTableDataKeyStockout(name, key) {
8
- const arr = name.split('.')
9
- const { dataKey } = this.config.contents[arr[2]]
10
- const keyArr = dataKey.split('_')
11
- let newDataKey
12
- // 当前有这个key则去掉
13
- if (keyArr.includes(key)) {
14
- newDataKey = _.without(keyArr, key)
15
- } else {
16
- newDataKey = _.concat(keyArr, key)
17
- }
18
- newDataKey = _.sortBy(newDataKey, [
19
- o => o === 'money',
20
- o => o === 'quantity',
21
- o => o === 'multi',
22
- o => o === 'orders'
23
- ])
24
-
25
- this.config.contents[arr[2]].dataKey = newDataKey.join('_')
26
- }
27
- }
28
-
29
- export default new Store()