gm-printer 10.14.1-alpha.5 → 10.14.1-alpha.8
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 +1 -1
- package/package.json +1 -1
- package/src/common/editor_store.js +7 -7
- package/src/finance_voucher/components/finance_batch_printer.js +36 -0
- package/src/finance_voucher/components/table.js +343 -0
- package/src/finance_voucher/components/table_subtotal_tr.js +147 -0
- package/src/finance_voucher/finance_printer.js +312 -0
- package/src/index.js +4 -2
- package/src/printer/do_print.js +31 -1
- package/src/printer/index.js +8 -2
- package/src/printer/page.js +8 -3
- package/src/printer/store.js +88 -5
- package/src/printer/style.lesss +4 -0
- package/src/util.js +5 -7
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","/Users/yancheng/gm/gm-open-source/gm-printer/src/printer/do_print.js":"9","/Users/yancheng/gm/gm-open-source/gm-printer/src/common/editor_special_field.js":"10","/Users/yancheng/gm/gm-open-source/gm-printer/src/common/hoc_with_store.js":"11","/Users/yancheng/gm/gm-open-source/gm-printer/src/common/hoc_with_shadow_dom.js":"12","/Users/yancheng/gm/gm-open-source/gm-printer/src/common/editor_title.js":"13","/Users/yancheng/gm/gm-open-source/gm-printer/src/common/editor_store.js":"14","/Users/yancheng/gm/gm-open-source/gm-printer/src/common/editor_add_field.js":"15","/Users/yancheng/gm/gm-open-source/gm-printer/src/common/editor_page_summary.js":"16","/Users/yancheng/gm/gm-open-source/gm-printer/src/editor_account/editor.js":"17","/Users/yancheng/gm/gm-open-source/gm-printer/src/editor_account/context_menu.js":"18","/Users/yancheng/gm/gm-open-source/gm-printer/src/editor_purchase/context_menu.js":"19","/Users/yancheng/gm/gm-open-source/gm-printer/src/common/editor_customize_config.js":"20","/Users/yancheng/gm/gm-open-source/gm-printer/src/common/editor_edit_field.js":"21","/Users/yancheng/gm/gm-open-source/gm-printer/src/common/component.js":"22","/Users/yancheng/gm/gm-open-source/gm-printer/src/printer/panel.js":"23"},{"size":9379,"mtime":1643448762149,"results":"24","hashOfConfig":"25"},{"size":15108,"mtime":1646982806457,"results":"26","hashOfConfig":"25"},{"size":4244,"mtime":1635494969691,"results":"27","hashOfConfig":"25"},{"size":4501,"mtime":1646970942704,"results":"28","hashOfConfig":"25"},{"size":616,"mtime":1621235314060,"results":"29","hashOfConfig":"30"},{"size":9693,"mtime":1621242097206,"results":"31","hashOfConfig":"30"},{"size":7258,"mtime":1639037857730,"results":"32","hashOfConfig":"25"},{"size":10283,"mtime":1646979851812,"results":"33","hashOfConfig":"25"},{"size":3119,"mtime":1634191808754,"results":"34","hashOfConfig":"25"},{"size":1113,"mtime":1635407660514,"results":"35","hashOfConfig":"25"},{"size":4349,"mtime":1646815933499,"results":"36","hashOfConfig":"25"},{"size":861,"mtime":1635246075403,"results":"37","hashOfConfig":"25"},{"size":3260,"mtime":1635334661529,"results":"38","hashOfConfig":"25"},{"size":26475,"mtime":1646982227981,"results":"39","hashOfConfig":"25"},{"size":1907,"mtime":1635492860490,"results":"40","hashOfConfig":"25"},{"size":3548,"mtime":1635409410379,"results":"41","hashOfConfig":"25"},{"size":2989,"mtime":1635495718901,"results":"42","hashOfConfig":"25"},{"size":3399,"mtime":1646816404368,"results":"43","hashOfConfig":"25"},{"size":2456,"mtime":1646721857196,"results":"44","hashOfConfig":"25"},{"size":1159,"mtime":1646970893747,"results":"45","hashOfConfig":"25"},{"size":13280,"mtime":1646901618757,"results":"46","hashOfConfig":"25"},{"size":14804,"mtime":1646895235712,"results":"47","hashOfConfig":"25"},{"size":3005,"mtime":1647228414919,"results":"48","hashOfConfig":"25"},{"filePath":"49","messages":"50","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},"1j0d8vf",{"filePath":"51","messages":"52","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"53","messages":"54","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"55","messages":"56","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"57","messages":"58","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},"175njjo",{"filePath":"59","messages":"60","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"61","messages":"62","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"63","messages":"64","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"65","messages":"66","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"67","messages":"68","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"69","messages":"70","errorCount":3,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"source":null},{"filePath":"71","messages":"72","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"73","messages":"74","errorCount":13,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"source":null},{"filePath":"75","messages":"76","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"77","messages":"78","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"79","messages":"80","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"81","messages":"82","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"83","messages":"84","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"85","messages":"86","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"87","messages":"88","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"89","messages":"90","errorCount":1,"warningCount":2,"fixableErrorCount":0,"fixableWarningCount":0,"source":null},{"filePath":"91","messages":"92","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"93","messages":"94","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",[],"/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/do_print.js",[],"/Users/yancheng/gm/gm-open-source/gm-printer/src/common/editor_special_field.js",[],"/Users/yancheng/gm/gm-open-source/gm-printer/src/common/hoc_with_store.js",["95","96","97"],"/Users/yancheng/gm/gm-open-source/gm-printer/src/common/hoc_with_shadow_dom.js",[],"/Users/yancheng/gm/gm-open-source/gm-printer/src/common/editor_title.js",["98","99","100","101","102","103","104","105","106","107","108","109","110"],"/Users/yancheng/gm/gm-open-source/gm-printer/src/common/editor_store.js",[],"/Users/yancheng/gm/gm-open-source/gm-printer/src/common/editor_add_field.js",[],"/Users/yancheng/gm/gm-open-source/gm-printer/src/common/editor_page_summary.js",[],"/Users/yancheng/gm/gm-open-source/gm-printer/src/editor_account/editor.js",[],"/Users/yancheng/gm/gm-open-source/gm-printer/src/editor_account/context_menu.js",[],"/Users/yancheng/gm/gm-open-source/gm-printer/src/editor_purchase/context_menu.js",[],"/Users/yancheng/gm/gm-open-source/gm-printer/src/common/editor_customize_config.js",[],"/Users/yancheng/gm/gm-open-source/gm-printer/src/common/editor_edit_field.js",["111","112","113"],"/Users/yancheng/gm/gm-open-source/gm-printer/src/common/component.js",[],"/Users/yancheng/gm/gm-open-source/gm-printer/src/printer/panel.js",[],{"ruleId":"114","severity":2,"message":"115","line":10,"column":29,"nodeType":"116","endLine":10,"endColumn":35},{"ruleId":"114","severity":2,"message":"117","line":10,"column":43,"nodeType":"116","endLine":10,"endColumn":51},{"ruleId":"114","severity":2,"message":"117","line":147,"column":63,"nodeType":"116","endLine":147,"endColumn":71},{"ruleId":"114","severity":2,"message":"118","line":47,"column":13,"nodeType":"119","messageId":"120","endLine":47,"endColumn":22},{"ruleId":"114","severity":2,"message":"121","line":48,"column":30,"nodeType":"116","messageId":"120","endLine":48,"endColumn":36},{"ruleId":"114","severity":2,"message":"122","line":49,"column":31,"nodeType":"116","messageId":"120","endLine":49,"endColumn":47},{"ruleId":"114","severity":2,"message":"122","line":50,"column":21,"nodeType":"116","messageId":"120","endLine":50,"endColumn":37},{"ruleId":"114","severity":2,"message":"118","line":56,"column":13,"nodeType":"119","messageId":"120","endLine":56,"endColumn":22},{"ruleId":"114","severity":2,"message":"123","line":59,"column":20,"nodeType":"116","messageId":"120","endLine":59,"endColumn":32},{"ruleId":"114","severity":2,"message":"121","line":61,"column":23,"nodeType":"116","messageId":"120","endLine":61,"endColumn":29},{"ruleId":"114","severity":2,"message":"124","line":61,"column":30,"nodeType":"116","messageId":"120","endLine":61,"endColumn":34},{"ruleId":"114","severity":2,"message":"125","line":63,"column":15,"nodeType":"116","messageId":"120","endLine":63,"endColumn":19},{"ruleId":"114","severity":2,"message":"118","line":67,"column":23,"nodeType":"119","messageId":"120","endLine":67,"endColumn":32},{"ruleId":"114","severity":2,"message":"121","line":70,"column":32,"nodeType":"116","messageId":"120","endLine":70,"endColumn":38},{"ruleId":"114","severity":2,"message":"118","line":78,"column":13,"nodeType":"119","messageId":"120","endLine":78,"endColumn":22},{"ruleId":"114","severity":2,"message":"121","line":84,"column":42,"nodeType":"116","messageId":"120","endLine":84,"endColumn":48},{"ruleId":"126","severity":1,"message":"127","line":265,"column":13,"nodeType":"128","endLine":265,"endColumn":49},{"ruleId":"126","severity":1,"message":"127","line":283,"column":13,"nodeType":"128","endLine":283,"endColumn":56},{"ruleId":"129","severity":2,"message":"130","line":436,"column":22,"nodeType":"131","messageId":"132","endLine":436,"endColumn":31},"react/prop-types","'config' is missing in props validation","Identifier","'mockData' is missing in props validation","'editStore' is missing in props validation","Property","missingPropType","'editStore.config' is missing in props validation","'editStore.config.batchPrintConfig' is missing in props validation","'editStore.originConfig' is missing in props validation","'editStore.config.name' is missing in props validation","'editStore.init' is missing in props validation","react/jsx-handler-names","Handler function for onChange prop key must begin with 'handle'","JSXAttribute","gmfe/i18n-check","t函数的key只能为字符串常量(Literal),请使用单引号或双引号包裹","MemberExpression","isVariable"]
|
|
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/do_print.js":"9","/Users/yancheng/gm/gm-open-source/gm-printer/src/common/editor_special_field.js":"10","/Users/yancheng/gm/gm-open-source/gm-printer/src/common/hoc_with_store.js":"11","/Users/yancheng/gm/gm-open-source/gm-printer/src/common/hoc_with_shadow_dom.js":"12","/Users/yancheng/gm/gm-open-source/gm-printer/src/common/editor_title.js":"13","/Users/yancheng/gm/gm-open-source/gm-printer/src/common/editor_store.js":"14","/Users/yancheng/gm/gm-open-source/gm-printer/src/common/editor_add_field.js":"15","/Users/yancheng/gm/gm-open-source/gm-printer/src/common/editor_page_summary.js":"16","/Users/yancheng/gm/gm-open-source/gm-printer/src/editor_account/editor.js":"17","/Users/yancheng/gm/gm-open-source/gm-printer/src/editor_account/context_menu.js":"18","/Users/yancheng/gm/gm-open-source/gm-printer/src/editor_purchase/context_menu.js":"19","/Users/yancheng/gm/gm-open-source/gm-printer/src/common/editor_customize_config.js":"20","/Users/yancheng/gm/gm-open-source/gm-printer/src/common/editor_edit_field.js":"21","/Users/yancheng/gm/gm-open-source/gm-printer/src/common/component.js":"22","/Users/yancheng/gm/gm-open-source/gm-printer/src/printer/panel.js":"23"},{"size":9379,"mtime":1643448762149,"results":"24","hashOfConfig":"25"},{"size":15785,"mtime":1647332608072,"results":"26","hashOfConfig":"25"},{"size":4244,"mtime":1635494969691,"results":"27","hashOfConfig":"25"},{"size":4501,"mtime":1646970942704,"results":"28","hashOfConfig":"25"},{"size":616,"mtime":1621235314060,"results":"29","hashOfConfig":"30"},{"size":9693,"mtime":1621242097206,"results":"31","hashOfConfig":"30"},{"size":7258,"mtime":1639037857730,"results":"32","hashOfConfig":"25"},{"size":10283,"mtime":1646979851812,"results":"33","hashOfConfig":"25"},{"size":3119,"mtime":1634191808754,"results":"34","hashOfConfig":"25"},{"size":1113,"mtime":1635407660514,"results":"35","hashOfConfig":"25"},{"size":4349,"mtime":1646815933499,"results":"36","hashOfConfig":"25"},{"size":861,"mtime":1635246075403,"results":"37","hashOfConfig":"25"},{"size":3260,"mtime":1635334661529,"results":"38","hashOfConfig":"25"},{"size":26478,"mtime":1647331538032,"results":"39","hashOfConfig":"25"},{"size":1907,"mtime":1635492860490,"results":"40","hashOfConfig":"25"},{"size":3548,"mtime":1635409410379,"results":"41","hashOfConfig":"25"},{"size":2989,"mtime":1635495718901,"results":"42","hashOfConfig":"25"},{"size":3399,"mtime":1646816404368,"results":"43","hashOfConfig":"25"},{"size":2456,"mtime":1646721857196,"results":"44","hashOfConfig":"25"},{"size":1159,"mtime":1646970893747,"results":"45","hashOfConfig":"25"},{"size":13280,"mtime":1646901618757,"results":"46","hashOfConfig":"25"},{"size":14804,"mtime":1646895235712,"results":"47","hashOfConfig":"25"},{"size":3005,"mtime":1647228414919,"results":"48","hashOfConfig":"25"},{"filePath":"49","messages":"50","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},"1j0d8vf",{"filePath":"51","messages":"52","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"53","messages":"54","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"55","messages":"56","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"57","messages":"58","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},"175njjo",{"filePath":"59","messages":"60","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"61","messages":"62","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"63","messages":"64","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"65","messages":"66","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"67","messages":"68","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"69","messages":"70","errorCount":3,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"source":null},{"filePath":"71","messages":"72","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"73","messages":"74","errorCount":13,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"source":null},{"filePath":"75","messages":"76","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"77","messages":"78","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"79","messages":"80","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"81","messages":"82","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"83","messages":"84","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"85","messages":"86","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"87","messages":"88","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"89","messages":"90","errorCount":1,"warningCount":2,"fixableErrorCount":0,"fixableWarningCount":0,"source":null},{"filePath":"91","messages":"92","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"93","messages":"94","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",[],"/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/do_print.js",[],"/Users/yancheng/gm/gm-open-source/gm-printer/src/common/editor_special_field.js",[],"/Users/yancheng/gm/gm-open-source/gm-printer/src/common/hoc_with_store.js",["95","96","97"],"/Users/yancheng/gm/gm-open-source/gm-printer/src/common/hoc_with_shadow_dom.js",[],"/Users/yancheng/gm/gm-open-source/gm-printer/src/common/editor_title.js",["98","99","100","101","102","103","104","105","106","107","108","109","110"],"/Users/yancheng/gm/gm-open-source/gm-printer/src/common/editor_store.js",[],"/Users/yancheng/gm/gm-open-source/gm-printer/src/common/editor_add_field.js",[],"/Users/yancheng/gm/gm-open-source/gm-printer/src/common/editor_page_summary.js",[],"/Users/yancheng/gm/gm-open-source/gm-printer/src/editor_account/editor.js",[],"/Users/yancheng/gm/gm-open-source/gm-printer/src/editor_account/context_menu.js",[],"/Users/yancheng/gm/gm-open-source/gm-printer/src/editor_purchase/context_menu.js",[],"/Users/yancheng/gm/gm-open-source/gm-printer/src/common/editor_customize_config.js",[],"/Users/yancheng/gm/gm-open-source/gm-printer/src/common/editor_edit_field.js",["111","112","113"],"/Users/yancheng/gm/gm-open-source/gm-printer/src/common/component.js",[],"/Users/yancheng/gm/gm-open-source/gm-printer/src/printer/panel.js",[],{"ruleId":"114","severity":2,"message":"115","line":10,"column":29,"nodeType":"116","endLine":10,"endColumn":35},{"ruleId":"114","severity":2,"message":"117","line":10,"column":43,"nodeType":"116","endLine":10,"endColumn":51},{"ruleId":"114","severity":2,"message":"117","line":147,"column":63,"nodeType":"116","endLine":147,"endColumn":71},{"ruleId":"114","severity":2,"message":"118","line":47,"column":13,"nodeType":"119","messageId":"120","endLine":47,"endColumn":22},{"ruleId":"114","severity":2,"message":"121","line":48,"column":30,"nodeType":"116","messageId":"120","endLine":48,"endColumn":36},{"ruleId":"114","severity":2,"message":"122","line":49,"column":31,"nodeType":"116","messageId":"120","endLine":49,"endColumn":47},{"ruleId":"114","severity":2,"message":"122","line":50,"column":21,"nodeType":"116","messageId":"120","endLine":50,"endColumn":37},{"ruleId":"114","severity":2,"message":"118","line":56,"column":13,"nodeType":"119","messageId":"120","endLine":56,"endColumn":22},{"ruleId":"114","severity":2,"message":"123","line":59,"column":20,"nodeType":"116","messageId":"120","endLine":59,"endColumn":32},{"ruleId":"114","severity":2,"message":"121","line":61,"column":23,"nodeType":"116","messageId":"120","endLine":61,"endColumn":29},{"ruleId":"114","severity":2,"message":"124","line":61,"column":30,"nodeType":"116","messageId":"120","endLine":61,"endColumn":34},{"ruleId":"114","severity":2,"message":"125","line":63,"column":15,"nodeType":"116","messageId":"120","endLine":63,"endColumn":19},{"ruleId":"114","severity":2,"message":"118","line":67,"column":23,"nodeType":"119","messageId":"120","endLine":67,"endColumn":32},{"ruleId":"114","severity":2,"message":"121","line":70,"column":32,"nodeType":"116","messageId":"120","endLine":70,"endColumn":38},{"ruleId":"114","severity":2,"message":"118","line":78,"column":13,"nodeType":"119","messageId":"120","endLine":78,"endColumn":22},{"ruleId":"114","severity":2,"message":"121","line":84,"column":42,"nodeType":"116","messageId":"120","endLine":84,"endColumn":48},{"ruleId":"126","severity":1,"message":"127","line":265,"column":13,"nodeType":"128","endLine":265,"endColumn":49},{"ruleId":"126","severity":1,"message":"127","line":283,"column":13,"nodeType":"128","endLine":283,"endColumn":56},{"ruleId":"129","severity":2,"message":"130","line":436,"column":22,"nodeType":"131","messageId":"132","endLine":436,"endColumn":31},"react/prop-types","'config' is missing in props validation","Identifier","'mockData' is missing in props validation","'editStore' is missing in props validation","Property","missingPropType","'editStore.config' is missing in props validation","'editStore.config.batchPrintConfig' is missing in props validation","'editStore.originConfig' is missing in props validation","'editStore.config.name' is missing in props validation","'editStore.init' is missing in props validation","react/jsx-handler-names","Handler function for onChange prop key must begin with 'handle'","JSXAttribute","gmfe/i18n-check","t函数的key只能为字符串常量(Literal),请使用单引号或双引号包裹","MemberExpression","isVariable"]
|
package/package.json
CHANGED
|
@@ -132,12 +132,6 @@ class EditorStore {
|
|
|
132
132
|
const table = this.mockData._table[dataKey]
|
|
133
133
|
this.setAutoFillingConfig(isAutoFilling)
|
|
134
134
|
|
|
135
|
-
if (isAutoFilling) {
|
|
136
|
-
table.push(...this.getFilledTableData(table))
|
|
137
|
-
} else {
|
|
138
|
-
this.clearExtraTableData(dataKey)
|
|
139
|
-
return
|
|
140
|
-
}
|
|
141
135
|
set(this.config, {
|
|
142
136
|
autoFillConfig: {
|
|
143
137
|
region: this.selectedRegion,
|
|
@@ -145,6 +139,12 @@ class EditorStore {
|
|
|
145
139
|
checked: isAutoFilling
|
|
146
140
|
}
|
|
147
141
|
})
|
|
142
|
+
if (isAutoFilling) {
|
|
143
|
+
table.push(...this.getFilledTableData(table))
|
|
144
|
+
} else {
|
|
145
|
+
this.clearExtraTableData(dataKey)
|
|
146
|
+
return
|
|
147
|
+
}
|
|
148
148
|
this.mockData._table[dataKey] = table
|
|
149
149
|
}
|
|
150
150
|
|
|
@@ -387,7 +387,7 @@ class EditorStore {
|
|
|
387
387
|
for (const [key, table] of Object.entries(tableData)) {
|
|
388
388
|
tableData[key] = table.filter(x => !x._isEmptyData)
|
|
389
389
|
}
|
|
390
|
-
this.setAutoFillingConfig(false)
|
|
390
|
+
// this.setAutoFillingConfig(false)
|
|
391
391
|
set(this.mockData, {
|
|
392
392
|
_table: tableData
|
|
393
393
|
})
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import Printer from '../finance_printer'
|
|
3
|
+
import _ from 'lodash'
|
|
4
|
+
import PropTypes from 'prop-types'
|
|
5
|
+
|
|
6
|
+
class BatchPrinter extends React.Component {
|
|
7
|
+
constructor(props) {
|
|
8
|
+
super(props)
|
|
9
|
+
this.ready = 0
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
handleReady = () => {
|
|
13
|
+
this.ready++
|
|
14
|
+
if (this.ready === this.props.list.length) {
|
|
15
|
+
this.props.onReady()
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
render() {
|
|
20
|
+
const { list } = this.props
|
|
21
|
+
return _.map(list, ({ config, data }, i) => (
|
|
22
|
+
<Printer key={i} data={data} config={config} onReady={this.handleReady} />
|
|
23
|
+
))
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
BatchPrinter.propTypes = {
|
|
28
|
+
list: PropTypes.array.isRequired,
|
|
29
|
+
onReady: PropTypes.func
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
BatchPrinter.defaultProps = {
|
|
33
|
+
onReady: _.noop
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export default BatchPrinter
|
|
@@ -0,0 +1,343 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import PropTypes from 'prop-types'
|
|
3
|
+
import _ from 'lodash'
|
|
4
|
+
import {
|
|
5
|
+
dispatchMsg,
|
|
6
|
+
getDataKey,
|
|
7
|
+
getHeight,
|
|
8
|
+
getMultiNumber,
|
|
9
|
+
getTableColumnName,
|
|
10
|
+
getWidth,
|
|
11
|
+
isMultiTable
|
|
12
|
+
} from '../../util'
|
|
13
|
+
import { inject, observer } from 'mobx-react'
|
|
14
|
+
import classNames from 'classnames'
|
|
15
|
+
import { MULTI_SUFFIX } from '../../config'
|
|
16
|
+
import SpecialTr from '../../printer/table_special_tr'
|
|
17
|
+
import SubtotalTr from './table_subtotal_tr'
|
|
18
|
+
import PageSummary from '../../printer/page_summary'
|
|
19
|
+
|
|
20
|
+
@inject('printerStore')
|
|
21
|
+
@observer
|
|
22
|
+
class Table extends React.Component {
|
|
23
|
+
constructor(props) {
|
|
24
|
+
super(props)
|
|
25
|
+
this.ref = React.createRef()
|
|
26
|
+
this.state = {
|
|
27
|
+
index: null
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
componentDidMount() {
|
|
32
|
+
const { name, printerStore } = this.props
|
|
33
|
+
|
|
34
|
+
if (!printerStore.ready) {
|
|
35
|
+
const $table = this.ref.current.querySelector('table')
|
|
36
|
+
const tHead = $table.querySelector('thead')
|
|
37
|
+
const ths = tHead.querySelectorAll('th') || []
|
|
38
|
+
const trs = $table.querySelectorAll('tbody tr') || []
|
|
39
|
+
const detailsDiv = $table.querySelectorAll('tr td .b-table-details')
|
|
40
|
+
|
|
41
|
+
printerStore.setHeight(name, getHeight($table))
|
|
42
|
+
|
|
43
|
+
printerStore.setTable(name, {
|
|
44
|
+
head: {
|
|
45
|
+
height: getHeight(tHead),
|
|
46
|
+
widths: _.map(ths, th => getWidth(th))
|
|
47
|
+
},
|
|
48
|
+
body: {
|
|
49
|
+
heights: _.map(trs, tr => getHeight(tr)),
|
|
50
|
+
children: _.map(detailsDiv, div => getHeight(div))
|
|
51
|
+
}
|
|
52
|
+
})
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
handleClick = e => {
|
|
57
|
+
const { name } = this.props
|
|
58
|
+
const { index } = e.target.dataset
|
|
59
|
+
|
|
60
|
+
dispatchMsg('gm-printer-select', {
|
|
61
|
+
selected: getTableColumnName(name, index)
|
|
62
|
+
})
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
handleDragStart = e => {
|
|
66
|
+
const { name } = this.props
|
|
67
|
+
const { index } = e.target.dataset
|
|
68
|
+
|
|
69
|
+
this.setState({
|
|
70
|
+
index
|
|
71
|
+
})
|
|
72
|
+
|
|
73
|
+
dispatchMsg('gm-printer-select', {
|
|
74
|
+
selected: getTableColumnName(name, index)
|
|
75
|
+
})
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
handleSelectedRegion = () => {
|
|
79
|
+
const { name } = this.props
|
|
80
|
+
|
|
81
|
+
dispatchMsg('gm-printer-select-region', { selected: name })
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
handleDrop = e => {
|
|
85
|
+
const { index } = e.target.dataset
|
|
86
|
+
|
|
87
|
+
if (this.state.index !== index) {
|
|
88
|
+
dispatchMsg('gm-printer-table-drag', {
|
|
89
|
+
source: this.state.index,
|
|
90
|
+
target: index
|
|
91
|
+
})
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
handleDragOver = e => {
|
|
96
|
+
e.preventDefault()
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
getColumns = () => {
|
|
100
|
+
const {
|
|
101
|
+
config: { columns, dataKey }
|
|
102
|
+
} = this.props
|
|
103
|
+
const columns1 = columns.map((val, index) => ({ ...val, index }))
|
|
104
|
+
// 如果是多列表格
|
|
105
|
+
if (isMultiTable(dataKey)) {
|
|
106
|
+
// 多栏商品的第二列有点特殊,都带 _MULTI_SUFFIX 后缀
|
|
107
|
+
let res = columns1
|
|
108
|
+
const colNumber = getMultiNumber(dataKey)
|
|
109
|
+
for (let i = 2; i <= colNumber; i++) {
|
|
110
|
+
const colNum = i > 2 ? i : '' // 栏数
|
|
111
|
+
const columnsI = columns.map((val, index) => {
|
|
112
|
+
const data = {
|
|
113
|
+
...val,
|
|
114
|
+
index,
|
|
115
|
+
text: val.text.replace(
|
|
116
|
+
/{{(price\()?列\.([^{{]+)}}/g,
|
|
117
|
+
(s, s1, s2) => {
|
|
118
|
+
if (s1) {
|
|
119
|
+
// 有price函数插进来
|
|
120
|
+
const mix_suffix = s2.replace(/\*/, () => `${MULTI_SUFFIX}*`)
|
|
121
|
+
return `{{${s1}列.${mix_suffix}${colNum}}}`
|
|
122
|
+
} else {
|
|
123
|
+
return `{{列.${s2}${MULTI_SUFFIX}${colNum}}}`
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
) // {{列.xx}} => {{列.xxMULTI_SUFFIXi}}
|
|
127
|
+
}
|
|
128
|
+
// 多栏商品的明细取 __details_MULTI_SUFFIX
|
|
129
|
+
if (val.specialDetailsKey)
|
|
130
|
+
data.specialDetailsKey =
|
|
131
|
+
val.specialDetailsKey + `${MULTI_SUFFIX}${colNum}`
|
|
132
|
+
return data
|
|
133
|
+
})
|
|
134
|
+
res = res.concat(columnsI)
|
|
135
|
+
}
|
|
136
|
+
return res
|
|
137
|
+
} else {
|
|
138
|
+
return columns1
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
renderDefault() {
|
|
143
|
+
let {
|
|
144
|
+
config,
|
|
145
|
+
config: { dataKey, arrange, customerRowHeight = 23 },
|
|
146
|
+
name,
|
|
147
|
+
range,
|
|
148
|
+
pageIndex,
|
|
149
|
+
printerStore
|
|
150
|
+
} = this.props
|
|
151
|
+
|
|
152
|
+
// 数据
|
|
153
|
+
dataKey = getDataKey(dataKey, arrange)
|
|
154
|
+
const tableData = printerStore.data._table[dataKey] || []
|
|
155
|
+
|
|
156
|
+
// 列
|
|
157
|
+
const columns = this.getColumns()
|
|
158
|
+
// 列宽固定(避免跳页bug)
|
|
159
|
+
const thWidths = printerStore.tablesInfo[name]?.head.widths || []
|
|
160
|
+
// 每页合计在前
|
|
161
|
+
const subtotalTrPageSummary = () => {
|
|
162
|
+
return (
|
|
163
|
+
<>
|
|
164
|
+
<SubtotalTr
|
|
165
|
+
range={range}
|
|
166
|
+
config={config}
|
|
167
|
+
printerStore={printerStore}
|
|
168
|
+
/>
|
|
169
|
+
<PageSummary {...this.props} />
|
|
170
|
+
</>
|
|
171
|
+
)
|
|
172
|
+
}
|
|
173
|
+
// 合计在前
|
|
174
|
+
const PageSummarySubtotalTr = () => {
|
|
175
|
+
return (
|
|
176
|
+
<>
|
|
177
|
+
<PageSummary {...this.props} />
|
|
178
|
+
<SubtotalTr
|
|
179
|
+
range={range}
|
|
180
|
+
config={config}
|
|
181
|
+
printerStore={printerStore}
|
|
182
|
+
/>
|
|
183
|
+
</>
|
|
184
|
+
)
|
|
185
|
+
}
|
|
186
|
+
const getTdStyle = (index, style = {}) => {
|
|
187
|
+
const width = thWidths[index]
|
|
188
|
+
const { fontSize } = style
|
|
189
|
+
let tdStyle = {}
|
|
190
|
+
let minWidth = 24
|
|
191
|
+
|
|
192
|
+
if (!width) return tdStyle
|
|
193
|
+
if (fontSize) minWidth = _.parseInt(fontSize) * 2
|
|
194
|
+
if (width >= 150) {
|
|
195
|
+
tdStyle = {
|
|
196
|
+
minWidth: width
|
|
197
|
+
}
|
|
198
|
+
} else {
|
|
199
|
+
tdStyle = {
|
|
200
|
+
minWidth,
|
|
201
|
+
width
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
return tdStyle
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
return (
|
|
208
|
+
<table>
|
|
209
|
+
<thead>
|
|
210
|
+
<tr style={{ height: `${customerRowHeight}px` }}>
|
|
211
|
+
{_.map(columns, (col, i) => (
|
|
212
|
+
<th
|
|
213
|
+
key={i}
|
|
214
|
+
data-index={col.index}
|
|
215
|
+
data-name={getTableColumnName(name, col.index)}
|
|
216
|
+
draggable
|
|
217
|
+
style={{
|
|
218
|
+
...getTdStyle(i, col.headStyle),
|
|
219
|
+
...col.headStyle
|
|
220
|
+
}}
|
|
221
|
+
className={classNames({
|
|
222
|
+
active:
|
|
223
|
+
getTableColumnName(name, col.index) ===
|
|
224
|
+
printerStore.selected
|
|
225
|
+
})}
|
|
226
|
+
onClick={this.handleClick}
|
|
227
|
+
onDragStart={this.handleDragStart}
|
|
228
|
+
onDrop={this.handleDrop}
|
|
229
|
+
onDragOver={this.handleDragOver}
|
|
230
|
+
>
|
|
231
|
+
{col.head}
|
|
232
|
+
</th>
|
|
233
|
+
))}
|
|
234
|
+
</tr>
|
|
235
|
+
</thead>
|
|
236
|
+
<tbody>
|
|
237
|
+
{_.map(_.range(range.begin, range.end), i => {
|
|
238
|
+
const _special = tableData[i] && tableData[i]._special
|
|
239
|
+
if (_special)
|
|
240
|
+
return <SpecialTr key={i} config={config} data={_special} />
|
|
241
|
+
// 如果项为空对象展现一个占满一行的td
|
|
242
|
+
const isItemNone = !_.keys(tableData[i]).length
|
|
243
|
+
|
|
244
|
+
return (
|
|
245
|
+
<tr style={{ height: `${customerRowHeight}px` }} key={i}>
|
|
246
|
+
{isItemNone ? (
|
|
247
|
+
<td colSpan='99' />
|
|
248
|
+
) : (
|
|
249
|
+
_.map(columns, (col, j) => {
|
|
250
|
+
return (
|
|
251
|
+
<td
|
|
252
|
+
key={j}
|
|
253
|
+
data-name={getTableColumnName(name, col.index)}
|
|
254
|
+
style={{
|
|
255
|
+
...getTdStyle(j, col.style),
|
|
256
|
+
...col.style
|
|
257
|
+
}}
|
|
258
|
+
className={classNames({
|
|
259
|
+
active:
|
|
260
|
+
getTableColumnName(name, col.index) ===
|
|
261
|
+
printerStore.selected
|
|
262
|
+
})}
|
|
263
|
+
dangerouslySetInnerHTML={{
|
|
264
|
+
__html: col.isSpecialColumn
|
|
265
|
+
? printerStore.templateSpecialDetails(
|
|
266
|
+
col,
|
|
267
|
+
dataKey,
|
|
268
|
+
i
|
|
269
|
+
)
|
|
270
|
+
: printerStore
|
|
271
|
+
.templateFinance(
|
|
272
|
+
col.text,
|
|
273
|
+
dataKey,
|
|
274
|
+
i,
|
|
275
|
+
pageIndex
|
|
276
|
+
)
|
|
277
|
+
.replace(/\(\)/g, '')
|
|
278
|
+
}}
|
|
279
|
+
/>
|
|
280
|
+
)
|
|
281
|
+
})
|
|
282
|
+
)}
|
|
283
|
+
</tr>
|
|
284
|
+
)
|
|
285
|
+
})}
|
|
286
|
+
{this.props.config.subtotal.isCommutationPlace
|
|
287
|
+
? PageSummarySubtotalTr()
|
|
288
|
+
: subtotalTrPageSummary()}
|
|
289
|
+
</tbody>
|
|
290
|
+
</table>
|
|
291
|
+
)
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
renderEmptyTable() {
|
|
295
|
+
return (
|
|
296
|
+
<table>
|
|
297
|
+
<thead />
|
|
298
|
+
<tbody>
|
|
299
|
+
<tr />
|
|
300
|
+
</tbody>
|
|
301
|
+
</table>
|
|
302
|
+
)
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
render() {
|
|
306
|
+
let {
|
|
307
|
+
config: { className, dataKey, arrange },
|
|
308
|
+
name,
|
|
309
|
+
placeholder,
|
|
310
|
+
printerStore
|
|
311
|
+
} = this.props
|
|
312
|
+
dataKey = getDataKey(dataKey, arrange)
|
|
313
|
+
const tableData = printerStore.data._table[dataKey] || []
|
|
314
|
+
const active = printerStore.selectedRegion === name
|
|
315
|
+
|
|
316
|
+
return (
|
|
317
|
+
<div
|
|
318
|
+
ref={this.ref}
|
|
319
|
+
className={classNames(
|
|
320
|
+
'gm-printer-table',
|
|
321
|
+
'gm-printer-table-classname-' + (className || 'default'),
|
|
322
|
+
{ active }
|
|
323
|
+
)}
|
|
324
|
+
data-name={name}
|
|
325
|
+
data-placeholder={placeholder}
|
|
326
|
+
onClick={this.handleSelectedRegion}
|
|
327
|
+
>
|
|
328
|
+
{tableData.length ? this.renderDefault() : this.renderEmptyTable()}
|
|
329
|
+
</div>
|
|
330
|
+
)
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
Table.propTypes = {
|
|
335
|
+
config: PropTypes.object.isRequired,
|
|
336
|
+
name: PropTypes.string.isRequired,
|
|
337
|
+
range: PropTypes.object.isRequired,
|
|
338
|
+
pageIndex: PropTypes.number.isRequired,
|
|
339
|
+
placeholder: PropTypes.string,
|
|
340
|
+
printerStore: PropTypes.object
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
export default Table
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import i18next from '../../../locales'
|
|
3
|
+
import PropTypes from 'prop-types'
|
|
4
|
+
import _ from 'lodash'
|
|
5
|
+
import { MULTI_SUFFIX } from '../../config'
|
|
6
|
+
import Big from 'big.js'
|
|
7
|
+
import { coverDigit2Uppercase, getDataKey } from '../../util'
|
|
8
|
+
import { observer } from 'mobx-react'
|
|
9
|
+
import { get } from 'mobx'
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* 每页合计组件,分页计算后,根据range来统计每页合计数据
|
|
13
|
+
* @param props
|
|
14
|
+
* @returns {*}
|
|
15
|
+
*/
|
|
16
|
+
const SubtotalTr = props => {
|
|
17
|
+
const {
|
|
18
|
+
config: {
|
|
19
|
+
dataKey,
|
|
20
|
+
arrange,
|
|
21
|
+
subtotal,
|
|
22
|
+
subtotal: {
|
|
23
|
+
show,
|
|
24
|
+
isUpperCaseBefore, // 决定小写金额是否在前
|
|
25
|
+
isUpperLowerCaseSeparate, // 决定大小写金额是否分开在两端
|
|
26
|
+
style,
|
|
27
|
+
fields = [
|
|
28
|
+
{
|
|
29
|
+
name: i18next.t('出库金额'),
|
|
30
|
+
valueField: 'real_item_price'
|
|
31
|
+
}
|
|
32
|
+
],
|
|
33
|
+
displayName = false // 是否展示字段名
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
range,
|
|
37
|
+
printerStore: {
|
|
38
|
+
config: {
|
|
39
|
+
financeSpecialConfig: {
|
|
40
|
+
CapitalPrefix = '大写',
|
|
41
|
+
LowercasePrefix = '小写'
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
},
|
|
45
|
+
printerStore
|
|
46
|
+
} = props
|
|
47
|
+
const tableData = printerStore.data._table[getDataKey(dataKey, arrange)] || []
|
|
48
|
+
// 计算合计
|
|
49
|
+
const sumData = (list, field) => {
|
|
50
|
+
return _.reduce(
|
|
51
|
+
list,
|
|
52
|
+
(a, b) => {
|
|
53
|
+
let result = a
|
|
54
|
+
|
|
55
|
+
const _origin = b._origin || {}
|
|
56
|
+
const _origin2 = b['_origin' + MULTI_SUFFIX] || {}
|
|
57
|
+
|
|
58
|
+
result = a.plus(_origin[field] || 0)
|
|
59
|
+
if (_origin2[field]) {
|
|
60
|
+
result = result.plus(_origin2[field])
|
|
61
|
+
}
|
|
62
|
+
return result
|
|
63
|
+
},
|
|
64
|
+
Big(0)
|
|
65
|
+
).toFixed(2)
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
// 每页小计
|
|
69
|
+
// show 是否展示小计,fields<Array> 合计的字段和展现的name,displayName 是否显示名字
|
|
70
|
+
if (show && printerStore.ready) {
|
|
71
|
+
const list = tableData.slice(range.begin, range.end)
|
|
72
|
+
|
|
73
|
+
const sum = {}
|
|
74
|
+
|
|
75
|
+
_.each(fields, v => {
|
|
76
|
+
sum[v.name] = sumData(list, v.valueField)
|
|
77
|
+
})
|
|
78
|
+
|
|
79
|
+
// 定义每页小记的左右两侧内容
|
|
80
|
+
let subtotalLeftContent
|
|
81
|
+
let subtotalRightContent
|
|
82
|
+
|
|
83
|
+
for (const name in sum) {
|
|
84
|
+
const price = sum[name]
|
|
85
|
+
const priceUpperCase = get(subtotal, 'needUpperCase') // needUpperCase在初始模板中undefined,所以必须用这个方法
|
|
86
|
+
? coverDigit2Uppercase(price)
|
|
87
|
+
: ''
|
|
88
|
+
if (displayName) {
|
|
89
|
+
// 大写金额是否在前
|
|
90
|
+
if (isUpperCaseBefore) {
|
|
91
|
+
subtotalLeftContent = `${name}${priceUpperCase}`
|
|
92
|
+
subtotalRightContent = `(${LowercasePrefix || '小写'}:¥${price})`
|
|
93
|
+
} else {
|
|
94
|
+
subtotalLeftContent = `(${LowercasePrefix || '小写'}:¥${price})`
|
|
95
|
+
subtotalRightContent = `${name} ${priceUpperCase}`
|
|
96
|
+
}
|
|
97
|
+
} else {
|
|
98
|
+
if (isUpperCaseBefore) {
|
|
99
|
+
subtotalLeftContent = `${priceUpperCase}`
|
|
100
|
+
subtotalRightContent = `(${LowercasePrefix || '小写'}:¥${price})`
|
|
101
|
+
} else {
|
|
102
|
+
subtotalLeftContent = `(${LowercasePrefix || '小写'}:¥${price})`
|
|
103
|
+
subtotalRightContent = `${priceUpperCase}`
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
return (
|
|
109
|
+
<tr>
|
|
110
|
+
<td colSpan={99} style={{ ...style, height: '8mm' }}>
|
|
111
|
+
{/* 大写金额和小写金额分开在表格的两侧,通过控制类名实现,添加类名后,覆盖原来的居中、靠右靠左 */}
|
|
112
|
+
<div
|
|
113
|
+
className={
|
|
114
|
+
isUpperLowerCaseSeparate
|
|
115
|
+
? 'gm-printer-subtotal-UpperLowerCaseSeparate-outer'
|
|
116
|
+
: ''
|
|
117
|
+
}
|
|
118
|
+
style={{ margin: '0 30px' }}
|
|
119
|
+
>
|
|
120
|
+
{i18next.t(`${CapitalPrefix || '大写'}:`)}
|
|
121
|
+
{/* {i18next.t('每页合计')}: */}
|
|
122
|
+
<span
|
|
123
|
+
className={
|
|
124
|
+
isUpperLowerCaseSeparate
|
|
125
|
+
? 'gm-printer-subtotal-UpperLowerCaseSeparate-inter'
|
|
126
|
+
: ''
|
|
127
|
+
}
|
|
128
|
+
>
|
|
129
|
+
<span> {subtotalLeftContent} </span>
|
|
130
|
+
<span> {subtotalRightContent} </span>
|
|
131
|
+
</span>
|
|
132
|
+
</div>
|
|
133
|
+
</td>
|
|
134
|
+
</tr>
|
|
135
|
+
)
|
|
136
|
+
} else {
|
|
137
|
+
return null
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
SubtotalTr.propTypes = {
|
|
142
|
+
config: PropTypes.object.isRequired,
|
|
143
|
+
range: PropTypes.object.isRequired,
|
|
144
|
+
printStore: PropTypes.object
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
export default observer(SubtotalTr)
|
|
@@ -0,0 +1,312 @@
|
|
|
1
|
+
import i18next from '../../locales'
|
|
2
|
+
import React from 'react'
|
|
3
|
+
import classNames from 'classnames'
|
|
4
|
+
import { inject, observer, Provider } from 'mobx-react'
|
|
5
|
+
import PropTypes from 'prop-types'
|
|
6
|
+
import PrinterStore from '../printer/store'
|
|
7
|
+
import Page from '../printer/page'
|
|
8
|
+
import _ from 'lodash'
|
|
9
|
+
import Panel from '../printer/panel'
|
|
10
|
+
import Table from './components/table'
|
|
11
|
+
import MergePage from '../printer/merge_page'
|
|
12
|
+
|
|
13
|
+
// Header Sign Footer 相对特殊,要单独处理
|
|
14
|
+
const Header = props => (
|
|
15
|
+
<Panel {...props} name='header' placeholder={i18next.t('页眉')} />
|
|
16
|
+
)
|
|
17
|
+
|
|
18
|
+
const Sign = props => (
|
|
19
|
+
<Panel
|
|
20
|
+
{...props}
|
|
21
|
+
style={{
|
|
22
|
+
...props.style,
|
|
23
|
+
position: 'absolute',
|
|
24
|
+
left: 0,
|
|
25
|
+
right: 0
|
|
26
|
+
}}
|
|
27
|
+
name='sign'
|
|
28
|
+
placeholder={i18next.t('签名')}
|
|
29
|
+
/>
|
|
30
|
+
)
|
|
31
|
+
|
|
32
|
+
Sign.propTypes = {
|
|
33
|
+
style: PropTypes.object
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const Footer = props => (
|
|
37
|
+
<Panel
|
|
38
|
+
{...props}
|
|
39
|
+
style={{
|
|
40
|
+
...props.style,
|
|
41
|
+
position: 'absolute',
|
|
42
|
+
bottom: 0,
|
|
43
|
+
left: 0,
|
|
44
|
+
right: 0
|
|
45
|
+
}}
|
|
46
|
+
name='footer'
|
|
47
|
+
placeholder={i18next.t('页脚')}
|
|
48
|
+
/>
|
|
49
|
+
)
|
|
50
|
+
|
|
51
|
+
Footer.propTypes = {
|
|
52
|
+
style: PropTypes.object
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
@inject('printerStore')
|
|
56
|
+
@observer
|
|
57
|
+
class Printer extends React.Component {
|
|
58
|
+
constructor(props) {
|
|
59
|
+
super(props)
|
|
60
|
+
|
|
61
|
+
// 无实际意义,辅助 onReady,见 didMount
|
|
62
|
+
this.state = {}
|
|
63
|
+
|
|
64
|
+
props.printerStore.init(props.config, props.data)
|
|
65
|
+
props.printerStore.setSelected(props.selected)
|
|
66
|
+
props.printerStore.setSelectedRegion(props.selectedRegion)
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
UNSAFE_componentWillReceiveProps(nextProps) {
|
|
70
|
+
if (nextProps.selected !== this.props.selected) {
|
|
71
|
+
this.props.printerStore.setSelected(nextProps.selected)
|
|
72
|
+
}
|
|
73
|
+
if (nextProps.selectedRegion !== this.props.selectedRegion) {
|
|
74
|
+
this.props.printerStore.setSelectedRegion(nextProps.selectedRegion)
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
componentDidMount() {
|
|
79
|
+
const { printerStore, config } = this.props
|
|
80
|
+
const batchPrintConfig = config.batchPrintConfig
|
|
81
|
+
|
|
82
|
+
// 连续打印不需要计算
|
|
83
|
+
if (batchPrintConfig !== 2) {
|
|
84
|
+
// didMount 代表第一次渲染完成
|
|
85
|
+
printerStore.setReady(true)
|
|
86
|
+
|
|
87
|
+
// 开始计算,获取各种数据
|
|
88
|
+
// printerStore.computedPages()
|
|
89
|
+
printerStore.financeComputedPages()
|
|
90
|
+
}
|
|
91
|
+
// Printer 不是立马就呈现出最终样式,有个过程。这个过程需要时间,什么 ready,不太清楚,估借 setState 来获取过程结束时刻
|
|
92
|
+
this.setState({}, () => {
|
|
93
|
+
this.props.onReady()
|
|
94
|
+
})
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
renderBefore() {
|
|
98
|
+
const { printerStore } = this.props
|
|
99
|
+
const { config } = printerStore
|
|
100
|
+
|
|
101
|
+
return (
|
|
102
|
+
<Page isFontFamily>
|
|
103
|
+
<Header config={config.header} pageIndex={0} />
|
|
104
|
+
{_.map(config.contents, (content, index) => {
|
|
105
|
+
switch (content.type) {
|
|
106
|
+
case 'table':
|
|
107
|
+
// eslint-disable-next-line no-case-declarations
|
|
108
|
+
const list = printerStore.data._table[content.dataKey]
|
|
109
|
+
return (
|
|
110
|
+
<Table
|
|
111
|
+
key={`contents.table.${index}`}
|
|
112
|
+
name={`contents.table.${index}`}
|
|
113
|
+
config={content}
|
|
114
|
+
range={{ begin: 0, end: list?.length || 0 }}
|
|
115
|
+
pageIndex={0}
|
|
116
|
+
placeholder={`${i18next.t('区域')} ${index}`}
|
|
117
|
+
/>
|
|
118
|
+
)
|
|
119
|
+
|
|
120
|
+
default:
|
|
121
|
+
return (
|
|
122
|
+
<Panel
|
|
123
|
+
key={`contents.panel.${index}`}
|
|
124
|
+
name={`contents.panel.${index}`}
|
|
125
|
+
config={content}
|
|
126
|
+
pageIndex={0}
|
|
127
|
+
placeholder={`${i18next.t('区域')} ${index}`}
|
|
128
|
+
/>
|
|
129
|
+
)
|
|
130
|
+
}
|
|
131
|
+
})}
|
|
132
|
+
<Sign config={config.sign} pageIndex={0} />
|
|
133
|
+
<Footer config={config.footer} pageIndex={0} />
|
|
134
|
+
</Page>
|
|
135
|
+
)
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
renderPage() {
|
|
139
|
+
const { printerStore } = this.props
|
|
140
|
+
const { config } = printerStore
|
|
141
|
+
return (
|
|
142
|
+
<>
|
|
143
|
+
{_.map(printerStore.pages, (page, i) => {
|
|
144
|
+
const isLastPage = i === printerStore.pages.length - 1
|
|
145
|
+
|
|
146
|
+
return (
|
|
147
|
+
<Page key={i} isFontFamily>
|
|
148
|
+
<Header config={config.header} pageIndex={i} />
|
|
149
|
+
|
|
150
|
+
{_.map(page, (panel, ii) => {
|
|
151
|
+
switch (panel.type) {
|
|
152
|
+
case 'table':
|
|
153
|
+
return (
|
|
154
|
+
<Table
|
|
155
|
+
key={`contents.table.${panel.index}.${ii}`}
|
|
156
|
+
name={`contents.table.${panel.index}`}
|
|
157
|
+
config={config.contents[panel.index]}
|
|
158
|
+
range={{
|
|
159
|
+
begin: panel.begin,
|
|
160
|
+
end: panel.end
|
|
161
|
+
}}
|
|
162
|
+
placeholder={`${i18next.t('区域')} ${panel.index}`}
|
|
163
|
+
pageIndex={i}
|
|
164
|
+
/>
|
|
165
|
+
)
|
|
166
|
+
|
|
167
|
+
default:
|
|
168
|
+
return (
|
|
169
|
+
<Panel
|
|
170
|
+
key={`contents.panel.${panel.index}`}
|
|
171
|
+
name={`contents.panel.${panel.index}`}
|
|
172
|
+
config={config.contents[panel.index]}
|
|
173
|
+
pageIndex={i}
|
|
174
|
+
placeholder={`${i18next.t('区域')} ${panel.index}`}
|
|
175
|
+
/>
|
|
176
|
+
)
|
|
177
|
+
}
|
|
178
|
+
})}
|
|
179
|
+
{isLastPage && (
|
|
180
|
+
<Sign
|
|
181
|
+
config={config.sign}
|
|
182
|
+
pageIndex={i}
|
|
183
|
+
style={{ bottom: config.footer.style.height }}
|
|
184
|
+
/>
|
|
185
|
+
)}
|
|
186
|
+
<Footer config={config.footer} pageIndex={i} />
|
|
187
|
+
</Page>
|
|
188
|
+
)
|
|
189
|
+
})}
|
|
190
|
+
</>
|
|
191
|
+
)
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
renderMerge() {
|
|
195
|
+
const { printerStore } = this.props
|
|
196
|
+
const { config } = printerStore
|
|
197
|
+
|
|
198
|
+
return (
|
|
199
|
+
<MergePage>
|
|
200
|
+
<Header config={config.header} pageIndex={0} />
|
|
201
|
+
{_.map(config.contents, (content, index) => {
|
|
202
|
+
switch (content.type) {
|
|
203
|
+
case 'table':
|
|
204
|
+
// eslint-disable-next-line no-case-declarations
|
|
205
|
+
const list = printerStore.data._table[content.dataKey]
|
|
206
|
+
return (
|
|
207
|
+
<Table
|
|
208
|
+
key={`contents.table.${index}`}
|
|
209
|
+
name={`contents.table.${index}`}
|
|
210
|
+
config={content}
|
|
211
|
+
range={{ begin: 0, end: list?.length || 0 }}
|
|
212
|
+
pageIndex={0}
|
|
213
|
+
placeholder={`${i18next.t('区域')} ${index}`}
|
|
214
|
+
/>
|
|
215
|
+
)
|
|
216
|
+
|
|
217
|
+
default:
|
|
218
|
+
return (
|
|
219
|
+
<Panel
|
|
220
|
+
key={`contents.panel.${index}`}
|
|
221
|
+
name={`contents.panel.${index}`}
|
|
222
|
+
config={content}
|
|
223
|
+
pageIndex={0}
|
|
224
|
+
placeholder={`${i18next.t('区域')} ${index}`}
|
|
225
|
+
/>
|
|
226
|
+
)
|
|
227
|
+
}
|
|
228
|
+
})}
|
|
229
|
+
<Sign config={config.sign} pageIndex={0} />
|
|
230
|
+
<Footer config={config.footer} pageIndex={0} />
|
|
231
|
+
</MergePage>
|
|
232
|
+
)
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
doRender() {
|
|
236
|
+
const { printerStore, config } = this.props
|
|
237
|
+
// batchPrintConfig: 1 不连续打印(纸张会间断)2 连续打印(纸张连续打,不间断)
|
|
238
|
+
const batchPrintConfig = config.batchPrintConfig
|
|
239
|
+
if (batchPrintConfig === 2) {
|
|
240
|
+
return this.renderMerge()
|
|
241
|
+
} else {
|
|
242
|
+
// renderBefore ,拿到各种数据,哪些模块哪些内容放合适位置,切割表格
|
|
243
|
+
// renderPage,最终渲染打印的页面
|
|
244
|
+
return !printerStore.ready ? this.renderBefore() : this.renderPage()
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
render() {
|
|
249
|
+
const {
|
|
250
|
+
selected,
|
|
251
|
+
data,
|
|
252
|
+
config,
|
|
253
|
+
onReady,
|
|
254
|
+
selectedRegion,
|
|
255
|
+
printerStore,
|
|
256
|
+
...rest
|
|
257
|
+
} = this.props
|
|
258
|
+
|
|
259
|
+
const {
|
|
260
|
+
size: { width },
|
|
261
|
+
className,
|
|
262
|
+
style
|
|
263
|
+
} = printerStore.config.page
|
|
264
|
+
// batchPrintConfig: 1 不连续打印(纸张会间断)2 连续打印(纸张连续打,不间断)
|
|
265
|
+
const batchPrintConfig = config.batchPrintConfig
|
|
266
|
+
|
|
267
|
+
return (
|
|
268
|
+
<div
|
|
269
|
+
{...rest}
|
|
270
|
+
className={classNames('gm-printer', className)}
|
|
271
|
+
style={Object.assign({}, style, {
|
|
272
|
+
width,
|
|
273
|
+
breakAfter: batchPrintConfig === 2 ? 'auto' : 'always'
|
|
274
|
+
})}
|
|
275
|
+
>
|
|
276
|
+
{this.doRender()}
|
|
277
|
+
</div>
|
|
278
|
+
)
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
Printer.propTypes = {
|
|
283
|
+
className: PropTypes.oneOfType([PropTypes.string, PropTypes.object]),
|
|
284
|
+
style: PropTypes.object,
|
|
285
|
+
printerStore: PropTypes.object,
|
|
286
|
+
selected: PropTypes.string,
|
|
287
|
+
selectedRegion: PropTypes.string,
|
|
288
|
+
data: PropTypes.object.isRequired,
|
|
289
|
+
config: PropTypes.object.isRequired,
|
|
290
|
+
onReady: PropTypes.func
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
Printer.defaultProps = {
|
|
294
|
+
onReady: _.noop
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
class WithStorePrinter extends React.Component {
|
|
298
|
+
constructor(props) {
|
|
299
|
+
super(props)
|
|
300
|
+
this.printerStore = new PrinterStore()
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
render() {
|
|
304
|
+
return (
|
|
305
|
+
<Provider printerStore={this.printerStore}>
|
|
306
|
+
<Printer {...this.props} />
|
|
307
|
+
</Provider>
|
|
308
|
+
)
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
export default WithStorePrinter
|
package/src/index.js
CHANGED
|
@@ -16,7 +16,8 @@ import {
|
|
|
16
16
|
doPrint,
|
|
17
17
|
Printer,
|
|
18
18
|
getCSS,
|
|
19
|
-
getPrintContainerHTML
|
|
19
|
+
getPrintContainerHTML,
|
|
20
|
+
doBatchFinancePrint
|
|
20
21
|
} from './printer'
|
|
21
22
|
import { MULTI_SUFFIX, MULTI_SUFFIX3 } from './config'
|
|
22
23
|
|
|
@@ -41,5 +42,6 @@ export {
|
|
|
41
42
|
getCSS,
|
|
42
43
|
MULTI_SUFFIX,
|
|
43
44
|
MULTI_SUFFIX3,
|
|
44
|
-
getPrintContainerHTML
|
|
45
|
+
getPrintContainerHTML,
|
|
46
|
+
doBatchFinancePrint
|
|
45
47
|
}
|
package/src/printer/do_print.js
CHANGED
|
@@ -3,6 +3,7 @@ import ReactDOM from 'react-dom'
|
|
|
3
3
|
import Printer from './printer'
|
|
4
4
|
import getCSS from './get_css'
|
|
5
5
|
import BatchPrinter from './batch_printer'
|
|
6
|
+
import BatchFinancePrinter from '../finance_voucher/components/finance_batch_printer'
|
|
6
7
|
import { isZoom } from 'gm-util'
|
|
7
8
|
import { afterImgAndSvgLoaded } from '../util'
|
|
8
9
|
|
|
@@ -92,6 +93,25 @@ function toDoPrintBatch(list, isPrint = true) {
|
|
|
92
93
|
})
|
|
93
94
|
}
|
|
94
95
|
|
|
96
|
+
function toDoPrintFinanceBatch(list, isPrint = true) {
|
|
97
|
+
return new window.Promise(resolve => {
|
|
98
|
+
const $app = $printer.contentWindow.document.getElementById('appContainer')
|
|
99
|
+
ReactDOM.unmountComponentAtNode($app)
|
|
100
|
+
ReactDOM.render(
|
|
101
|
+
<BatchFinancePrinter
|
|
102
|
+
list={list}
|
|
103
|
+
onReady={() => {
|
|
104
|
+
afterImgAndSvgLoaded(() => {
|
|
105
|
+
isPrint && $printer.contentWindow.print()
|
|
106
|
+
resolve()
|
|
107
|
+
}, $app)
|
|
108
|
+
}}
|
|
109
|
+
/>,
|
|
110
|
+
$app
|
|
111
|
+
)
|
|
112
|
+
})
|
|
113
|
+
}
|
|
114
|
+
|
|
95
115
|
function doPrint({ data, config }, isTest) {
|
|
96
116
|
init({ isTest })
|
|
97
117
|
|
|
@@ -107,6 +127,16 @@ function doBatchPrint(
|
|
|
107
127
|
return toDoPrintBatch(list, extraCofnig.isPrint)
|
|
108
128
|
}
|
|
109
129
|
|
|
130
|
+
function doBatchFinancePrint(
|
|
131
|
+
list,
|
|
132
|
+
isTest,
|
|
133
|
+
extraCofnig = { isPrint: true, isTipZoom: true }
|
|
134
|
+
) {
|
|
135
|
+
init({ isTest, isTipZoom: extraCofnig.isTipZoom })
|
|
136
|
+
|
|
137
|
+
return toDoPrintFinanceBatch(list, extraCofnig.isPrint)
|
|
138
|
+
}
|
|
139
|
+
|
|
110
140
|
/**
|
|
111
141
|
* @description: 获取打印的html
|
|
112
142
|
*/
|
|
@@ -114,4 +144,4 @@ function getPrintContainerHTML() {
|
|
|
114
144
|
return $printer.contentWindow.document.getElementsByTagName('html')[0]
|
|
115
145
|
.innerHTML
|
|
116
146
|
}
|
|
117
|
-
export { doPrint, doBatchPrint, getPrintContainerHTML }
|
|
147
|
+
export { doPrint, doBatchPrint, getPrintContainerHTML, doBatchFinancePrint }
|
package/src/printer/index.js
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
import Printer from './printer'
|
|
2
2
|
import BatchPrinter from './batch_printer'
|
|
3
|
-
import {
|
|
3
|
+
import {
|
|
4
|
+
doPrint,
|
|
5
|
+
doBatchPrint,
|
|
6
|
+
getPrintContainerHTML,
|
|
7
|
+
doBatchFinancePrint
|
|
8
|
+
} from './do_print'
|
|
4
9
|
import getCSS from './get_css'
|
|
5
10
|
|
|
6
11
|
export {
|
|
@@ -9,5 +14,6 @@ export {
|
|
|
9
14
|
Printer,
|
|
10
15
|
BatchPrinter,
|
|
11
16
|
getCSS,
|
|
12
|
-
getPrintContainerHTML
|
|
17
|
+
getPrintContainerHTML,
|
|
18
|
+
doBatchFinancePrint
|
|
13
19
|
}
|
package/src/printer/page.js
CHANGED
|
@@ -2,6 +2,7 @@ import React from 'react'
|
|
|
2
2
|
import PropTypes from 'prop-types'
|
|
3
3
|
import { inject, observer } from 'mobx-react'
|
|
4
4
|
import { getHeight } from '../util'
|
|
5
|
+
import classNames from 'classnames'
|
|
5
6
|
|
|
6
7
|
@inject('printerStore')
|
|
7
8
|
@observer
|
|
@@ -18,13 +19,14 @@ class Page extends React.Component {
|
|
|
18
19
|
}
|
|
19
20
|
|
|
20
21
|
render() {
|
|
21
|
-
const { children, printerStore } = this.props
|
|
22
|
+
const { children, printerStore, isFontFamily } = this.props
|
|
22
23
|
const {
|
|
23
24
|
paddingTop,
|
|
24
25
|
paddingRight,
|
|
25
26
|
paddingBottom,
|
|
26
27
|
paddingLeft
|
|
27
28
|
} = printerStore.config.page.gap
|
|
29
|
+
console.log('isFontFamily', isFontFamily)
|
|
28
30
|
|
|
29
31
|
const {
|
|
30
32
|
size: { width, height },
|
|
@@ -36,7 +38,9 @@ class Page extends React.Component {
|
|
|
36
38
|
return (
|
|
37
39
|
<div
|
|
38
40
|
ref={this.ref}
|
|
39
|
-
className='gm-printer-page'
|
|
41
|
+
className={classNames('gm-printer-page', {
|
|
42
|
+
'gm-printer-page-fontFamily': isFontFamily
|
|
43
|
+
})}
|
|
40
44
|
style={{
|
|
41
45
|
...pageStyle,
|
|
42
46
|
boxSizing: 'content-box',
|
|
@@ -60,7 +64,8 @@ class Page extends React.Component {
|
|
|
60
64
|
}
|
|
61
65
|
|
|
62
66
|
Page.propTypes = {
|
|
63
|
-
printerStore: PropTypes.number
|
|
67
|
+
printerStore: PropTypes.number,
|
|
68
|
+
isFontFamily: PropTypes.bool
|
|
64
69
|
}
|
|
65
70
|
|
|
66
71
|
export default Page
|
package/src/printer/store.js
CHANGED
|
@@ -87,16 +87,27 @@ class PrinterStore {
|
|
|
87
87
|
}
|
|
88
88
|
|
|
89
89
|
get tableConfig() {
|
|
90
|
-
|
|
91
|
-
|
|
90
|
+
const { autoFillConfig } = this.config
|
|
91
|
+
if (!this.selectedRegion && !autoFillConfig?.checked) return null
|
|
92
|
+
const _selectedRegion = this.selectedRegion || autoFillConfig.region || ''
|
|
93
|
+
const arr = _selectedRegion.split('.')
|
|
92
94
|
const tableConfig = this.config.contents[arr[2]]
|
|
95
|
+
|
|
96
|
+
if (!_.has(tableConfig, 'dataKey')) return null
|
|
93
97
|
return tableConfig
|
|
94
98
|
}
|
|
95
99
|
|
|
96
100
|
get tableData() {
|
|
97
|
-
if (!this.
|
|
101
|
+
if (!this.tableConfig) return []
|
|
102
|
+
const { autoFillConfig } = this.config
|
|
98
103
|
const { dataKey } = this.tableConfig
|
|
99
104
|
|
|
105
|
+
if (autoFillConfig?.region) {
|
|
106
|
+
/** 当前数据 */
|
|
107
|
+
return this.data._table[dataKey] || []
|
|
108
|
+
}
|
|
109
|
+
if (!this.selectedRegion) return []
|
|
110
|
+
|
|
100
111
|
/** 当前数据 */
|
|
101
112
|
return this.data._table[dataKey] || []
|
|
102
113
|
}
|
|
@@ -133,6 +144,12 @@ class PrinterStore {
|
|
|
133
144
|
}
|
|
134
145
|
|
|
135
146
|
getNormalTableBodyHeights(heights, dataKey) {
|
|
147
|
+
if (!this.tableConfig) return heights
|
|
148
|
+
|
|
149
|
+
const len = this.tableData.length
|
|
150
|
+
// 如果是已经开了填充配置,回显的heights包括了填充的表格部分,关闭配置时,这种情况就要去掉填充的
|
|
151
|
+
if (_.gt(heights.length, len)) return heights.slice(0, len)
|
|
152
|
+
|
|
136
153
|
const hasEmptyData = this.tableData.some(x => x._isEmptyData)
|
|
137
154
|
const isOrderCategroy = dataKey === this.config?.autoFillConfig?.dataKey
|
|
138
155
|
const { customerRowHeight = TR_BASE_HEIGHT } = this.tableConfig
|
|
@@ -246,7 +263,6 @@ class PrinterStore {
|
|
|
246
263
|
table.body.heights,
|
|
247
264
|
dataKey
|
|
248
265
|
)
|
|
249
|
-
|
|
250
266
|
// 表格行的索引,用于table.slice(begin, end), 分割到不同页面中
|
|
251
267
|
let begin = 0
|
|
252
268
|
let end = 0
|
|
@@ -381,6 +397,46 @@ class PrinterStore {
|
|
|
381
397
|
this.remainPageHeight = +Big(this.pageHeight - currentPageHeight).toFixed(0)
|
|
382
398
|
}
|
|
383
399
|
|
|
400
|
+
@action
|
|
401
|
+
financeComputedPages() {
|
|
402
|
+
// 当前在处理 contents 的索引
|
|
403
|
+
let index = 0
|
|
404
|
+
/** 一页承载的内容. [object, object, ...] */
|
|
405
|
+
let page = []
|
|
406
|
+
const pageFixLineNum = this.config.financeSpecialConfig.pageFixLineNum
|
|
407
|
+
while (index < this.config.contents.length) {
|
|
408
|
+
const content = this.config.contents[index]
|
|
409
|
+
// debugger
|
|
410
|
+
const table = this.tablesInfo[`contents.table.${index}`]
|
|
411
|
+
// 表格行的索引,用于table.slice(begin, end), 分割到不同页面中
|
|
412
|
+
let begin = 0
|
|
413
|
+
let end = 0
|
|
414
|
+
|
|
415
|
+
if (content.type === 'table') {
|
|
416
|
+
while (end < table.body.heights.length) {
|
|
417
|
+
end += pageFixLineNum
|
|
418
|
+
page.push({
|
|
419
|
+
type: 'table',
|
|
420
|
+
index,
|
|
421
|
+
begin,
|
|
422
|
+
end
|
|
423
|
+
})
|
|
424
|
+
this.pages.push(page)
|
|
425
|
+
page = []
|
|
426
|
+
begin = end
|
|
427
|
+
}
|
|
428
|
+
index++
|
|
429
|
+
} else {
|
|
430
|
+
page.push({
|
|
431
|
+
type: 'panel',
|
|
432
|
+
index
|
|
433
|
+
})
|
|
434
|
+
index++
|
|
435
|
+
}
|
|
436
|
+
}
|
|
437
|
+
// this.pages.push(page)
|
|
438
|
+
}
|
|
439
|
+
|
|
384
440
|
template(text, pageIndex) {
|
|
385
441
|
// 做好保护,出错就返回 text
|
|
386
442
|
try {
|
|
@@ -416,6 +472,33 @@ class PrinterStore {
|
|
|
416
472
|
}
|
|
417
473
|
}
|
|
418
474
|
|
|
475
|
+
/**
|
|
476
|
+
* 配送单的定制化需求:限制表格里的字的个数,超出显示'...'
|
|
477
|
+
*/
|
|
478
|
+
templateFinance(text, dataKey, index, pageIndex) {
|
|
479
|
+
// 做好保护,出错就返回 text
|
|
480
|
+
try {
|
|
481
|
+
const list = this.data._table[dataKey] || this.data._table.orders
|
|
482
|
+
|
|
483
|
+
let res = _.template(text, {
|
|
484
|
+
interpolate: /{{([\s\S]+?)}}/g
|
|
485
|
+
})({
|
|
486
|
+
...this.data.common,
|
|
487
|
+
[i18next.t('列')]: list[index],
|
|
488
|
+
[i18next.t('当前页码')]: pageIndex + 1,
|
|
489
|
+
[i18next.t('页码总数')]: this.pages.length,
|
|
490
|
+
price: price // 提供一个价格处理函数
|
|
491
|
+
})
|
|
492
|
+
res =
|
|
493
|
+
text === '{{列.商品名}}' && res.length > 5
|
|
494
|
+
? `${res.slice(0, 5)}...`
|
|
495
|
+
: res
|
|
496
|
+
return res
|
|
497
|
+
} catch (err) {
|
|
498
|
+
return text
|
|
499
|
+
}
|
|
500
|
+
}
|
|
501
|
+
|
|
419
502
|
templateSpecialDetails(col, dataKey, index) {
|
|
420
503
|
// 做好保护,出错就返回 text
|
|
421
504
|
const { specialDetailsKey, text, detailLastColType, separator } = col
|
|
@@ -468,7 +551,7 @@ class PrinterStore {
|
|
|
468
551
|
@action.bound
|
|
469
552
|
changeTableData() {
|
|
470
553
|
const { autoFillConfig } = this.config
|
|
471
|
-
if (!
|
|
554
|
+
if (!this.isAutoFilling) return
|
|
472
555
|
const dataKey = autoFillConfig?.dataKey
|
|
473
556
|
const table = this.data._table[dataKey]
|
|
474
557
|
|
package/src/printer/style.lesss
CHANGED
package/src/util.js
CHANGED
|
@@ -141,9 +141,7 @@ const coverDigit2Uppercase = n => {
|
|
|
141
141
|
)
|
|
142
142
|
] + fraction[i]
|
|
143
143
|
}
|
|
144
|
-
|
|
145
|
-
right = right.replace(/(零分)/, '整').replace(/(零角整)/, '') || '整'
|
|
146
|
-
|
|
144
|
+
right = right.replace(/(零分)/, '').replace(/(零角)/, '零')
|
|
147
145
|
n = Math.floor(n)
|
|
148
146
|
|
|
149
147
|
for (i = 0; i < unit[0].length && n > 0; i++) {
|
|
@@ -157,10 +155,10 @@ const coverDigit2Uppercase = n => {
|
|
|
157
155
|
|
|
158
156
|
return (
|
|
159
157
|
head +
|
|
160
|
-
(
|
|
161
|
-
|
|
162
|
-
'
|
|
163
|
-
)
|
|
158
|
+
(
|
|
159
|
+
left.replace(/(零.)*零元/, '元').replace(/(零.)+/g, '零') +
|
|
160
|
+
(right === '零' ? '整' : right)
|
|
161
|
+
).replace(/^整$/, '零元整')
|
|
164
162
|
)
|
|
165
163
|
}
|
|
166
164
|
|