@things-factory/operato-wms 4.3.467 → 4.3.469

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.
@@ -1,4 +1,5 @@
1
1
  export const CARTON_LABEL_SETTING_KEY = 'carton-label'
2
+ export const CARTON_LABEL_BY_SKU_SETTING_KEY = 'carton-label-by-sku'
2
3
  export const HOME_DASHBOARD_SETTING_KEY = 'dashboard'
3
4
  export const LOCATION_LABEL_SETTING_KEY = 'location-label'
4
5
  export const PALLET_LABEL_SETTING_KEY = 'pallet-label'
@@ -1,18 +1,26 @@
1
+ import '@things-factory/grist-ui'
2
+
3
+ import { sendToPrinter } from '../../util'
1
4
  import { DirectPrinter } from '@things-factory/barcode-base'
2
5
  import { SingleColumnFormStyles } from '@things-factory/form-ui'
3
- import '@things-factory/grist-ui'
4
6
  import { i18next, localize } from '@things-factory/i18n-base'
5
7
  import { client, store } from '@things-factory/shell'
6
- import gql from 'graphql-tag'
7
8
  import { css, html, LitElement } from 'lit-element'
8
9
  import { connect } from 'pwa-helpers/connect-mixin'
9
- import { CARTON_LABEL_SETTING_KEY } from '../constants'
10
+ import { CARTON_LABEL_SETTING_KEY, CARTON_LABEL_BY_SKU_SETTING_KEY } from '../constants'
11
+
12
+ import gql from 'graphql-tag'
10
13
 
11
14
  class CartonLabelPopup extends connect(store)(localize(i18next)(LitElement)) {
12
15
  static get properties() {
13
16
  return {
14
- _cartonLabel: Object,
15
- bizplaceName: String
17
+ fixedType: String,
18
+ type: String,
19
+ data: Object,
20
+ bizplaceName: String,
21
+ _printer: Object,
22
+ _filters: Array,
23
+ _config: Object
16
24
  }
17
25
  }
18
26
 
@@ -27,99 +35,266 @@ class CartonLabelPopup extends connect(store)(localize(i18next)(LitElement)) {
27
35
  overflow-x: overlay;
28
36
  background-color: var(--main-section-background-color);
29
37
  }
38
+ .single-column-form {
39
+ width: unset;
40
+ max-width: unset;
41
+ }
30
42
  .button-container {
43
+ margin-top: auto;
44
+ text-align: center;
45
+ padding: 10px 0 0 0;
46
+ }
47
+ .container {
48
+ overflow-y: hidden;
49
+ display: flex;
50
+ flex: 1 1 0%;
51
+ }
52
+ .grist {
31
53
  display: flex;
32
54
  flex-direction: column;
33
- height: 100vh;
34
- justify-content: space-evenly;
35
- padding: 0 20px;
36
- margin: var(--button-container-margin);
37
- text-align: var(--button-container-align);
38
- background-color: var(--button-container-background);
55
+ flex: 1 1 0%;
56
+ overflow-y: auto;
39
57
  }
40
58
  `
41
59
  ]
42
60
  }
43
61
 
62
+ get dataGrist() {
63
+ return this.shadowRoot.querySelector('data-grist')
64
+ }
65
+
66
+ get printQtyInput() {
67
+ return this.shadowRoot.querySelector('input[name="printQty"]')
68
+ }
69
+
70
+ get printType() {
71
+ return this.shadowRoot.querySelector('select[name="printType"]')
72
+ }
73
+
74
+ constructor() {
75
+ super()
76
+ this.fixedType = null
77
+ this.type = null
78
+ this.bizplaceName = null
79
+ }
80
+
81
+ firstUpdated() {
82
+ this._config = {
83
+ rows: {
84
+ appendable: false,
85
+ selectable: { multiple: true }
86
+ },
87
+ pagination: { infinite: true },
88
+ columns: [
89
+ { type: 'gutter', gutterName: 'row-selector', multiple: true },
90
+ {
91
+ type: 'string',
92
+ name: 'batchId',
93
+ header: i18next.t('field.batch_id'),
94
+ width: 100
95
+ },
96
+ {
97
+ type: 'string',
98
+ name: 'productSku',
99
+ header: i18next.t('field.sku'),
100
+ width: 150
101
+ },
102
+ {
103
+ type: 'date',
104
+ name: 'manufactureDate',
105
+ header: i18next.t('field.manufacture_date'),
106
+ width: 150
107
+ },
108
+ {
109
+ type: 'integer',
110
+ name: 'packQty',
111
+ header: i18next.t('field.qty'),
112
+ width: 60
113
+ },
114
+ {
115
+ type: 'string',
116
+ name: 'packingType',
117
+ header: i18next.t('field.packing_type'),
118
+ width: 120
119
+ },
120
+ {
121
+ type: 'integer',
122
+ name: 'printQty',
123
+ header: i18next.t('field.print_qty'),
124
+ record: { editable: true, options: { min: 1 } },
125
+ width: 80
126
+ }
127
+ ]
128
+ }
129
+ }
130
+
44
131
  render() {
45
132
  return html`
46
- <form id="input-form" class="single-column-form">
47
- <fieldset>
48
- <label>${i18next.t('label.print_qty')}</label>
49
- <input name="printQty" type="number" min="1" />
50
- </fieldset>
51
- </form>
133
+ <div id="input-form" class="single-column-form">
134
+ <label>${i18next.t('label.printing_mode')}</label>
135
+ ${this.filterContent()}
136
+ </div>
137
+ ${this.printControl()}
52
138
  <div class="button-container">
53
139
  <mwc-button raised @click="${this._printLabel.bind(this)}" label="${i18next.t('button.print')}"></mwc-button>
54
140
  </div>
55
141
  `
56
142
  }
57
143
 
58
- get printQtyInput() {
59
- return this.shadowRoot.querySelector('input[name="printQty"]')
144
+ filterContent() {
145
+ if (this.fixedType) this._filters = this._filters.filter(filter => filter.value == this.fixedType)
146
+
147
+ return html`
148
+ <select
149
+ name="printType"
150
+ @change="${e => {
151
+ this.type = e.currentTarget.value
152
+ }}"
153
+ >
154
+ ${this._filters.map(filter => html` <option value="${filter.value}">${filter.name}</option> `)}
155
+ </select>
156
+ `
157
+ }
158
+
159
+ _fieldChange(e) {
160
+ var { after, before, column, record, row } = e.detail
161
+
162
+ if (column.record?.options?.min > after) {
163
+ this.dataGrist._data.records[row][column.name] = before
164
+ this.data = {
165
+ ...this.dataGrist._data
166
+ }
167
+ this._showToast({ message: `Minimum value of ${column.record.options.min} is required.` })
168
+ }
169
+ }
170
+
171
+ printControl() {
172
+ switch (this.type) {
173
+ case 'bySku':
174
+ this.data.records = this.data.records.map(record => {
175
+ record.printQty = record.packQty
176
+ return record
177
+ })
178
+ return html`
179
+ <div class="container">
180
+ <div class="grist">
181
+ <data-grist
182
+ id="grist"
183
+ .mode=${'GRID'}
184
+ .config=${this._config}
185
+ .data="${this.data}"
186
+ @field-change="${this._fieldChange.bind(this)}"
187
+ ></data-grist>
188
+ </div>
189
+ </div>
190
+ `
191
+ default:
192
+ return html`
193
+ <div class="single-column-form">
194
+ <label>${i18next.t('label.print_qty')}</label>
195
+ <input name="printQty" type="number" min="1" />
196
+ </div>
197
+ `
198
+ }
60
199
  }
61
200
 
62
201
  async _printLabel() {
202
+ if (!this._printer) {
203
+ this._printer = new DirectPrinter()
204
+ }
205
+
63
206
  try {
64
- let labelId = this._cartonLabel && this._cartonLabel.id
65
- this._validatePrintQty()
66
-
67
- const response = await client.query({
68
- query: gql`
69
- query generateCartonId($printQty: Int!, $type: String!) {
70
- generateCartonId(printQty: $printQty, type: $type) {
71
- cartonId
72
- }
73
- }
74
- `,
75
- variables: { printQty: parseInt(this.printQtyInput.value), type: 'inbound_carton_id' }
76
- })
207
+ const filters = this._filters
208
+ let labelId = filters.find(itm => itm.value == (this?.type ? this.type : 'default')).board.id
209
+ let bizplaceName = this.bizplaceName
210
+
211
+ switch (this.type) {
212
+ case 'bySku':
213
+ let selected = this.dataGrist.selected
77
214
 
78
- if (!response.errors) {
79
- const results = response.data.generateCartonId
215
+ if (selected.length > 0) {
216
+ let printData = []
80
217
 
81
- for (let i = 0; i < results.length; i++) {
82
- let searchParams = new URLSearchParams()
218
+ const cartonLabels = await this._getCartonId(selected.length)
83
219
 
84
- searchParams.append('carton', results[i].cartonId)
85
- searchParams.append('customer', this.bizplaceName)
86
- try {
87
- const response = await fetch(`label-command/${labelId}?${searchParams.toString()}`, {
88
- method: 'GET'
220
+ selected.forEach((obj, idx) => {
221
+ for (let index = 0; index < obj.printQty; index++) {
222
+ printData.push({
223
+ batchId: obj.batchId,
224
+ productSku: obj.productSku,
225
+ packingType: obj.packingType,
226
+ packQty: obj.packQty,
227
+ printQty: obj.printQty,
228
+ refNo: obj.refNo,
229
+ refNo2: obj.refNo2,
230
+ refNo3: obj.refNo3,
231
+ manufactureDate: new Date(obj.manufactureDate).toLocaleDateString(),
232
+ cartonId: cartonLabels[idx].cartonId,
233
+ customer: bizplaceName,
234
+ printCount: index + 1
235
+ })
236
+ }
89
237
  })
90
238
 
91
- if (response.status !== 200) {
92
- throw `Error : Can't get label command from server (response: ${response.status})`
239
+ for (let i = 0; i < printData.length; i++) {
240
+ await sendToPrinter(labelId, { ...printData[i], cartonId: printData[i].cartonId }, this._printer)
93
241
  }
242
+ }
243
+ break
244
+ default:
245
+ const printQty = this.printQtyInput?.value
246
+ if (isNaN(printQty) || printQty < 1) {
247
+ throw new Error(i18next.t('text.invalid_print_qty'))
248
+ }
94
249
 
95
- let command = await response.text()
250
+ const results = await this._getCartonId(printQty)
96
251
 
97
- if (!this.printer) {
98
- this.printer = new DirectPrinter()
252
+ for (let i = 0; i < results.length; i++) {
253
+ let printData = {
254
+ cartonId: results[i].cartonId,
255
+ customer: bizplaceName
99
256
  }
100
257
 
101
- await this.printer.print(command)
102
- } catch (ex) {
103
- delete this.printer
104
- throw ex
258
+ await sendToPrinter(labelId, printData, this._printer)
105
259
  }
106
- }
107
260
  }
108
261
  } catch (e) {
262
+ delete this._printer
109
263
  this._showToast(e)
110
264
  }
111
265
  }
112
266
 
113
- _validatePrintQty() {
114
- const printQty = this.printQtyInput.value
115
- if (isNaN(printQty) || printQty < 1) {
116
- throw new Error(i18next.t('text.invalid_print_qty'))
267
+ async _getCartonId(printQty) {
268
+ const response = await client.query({
269
+ query: gql`
270
+ query generateCartonId($printQty: Int!, $type: String!) {
271
+ generateCartonId(printQty: $printQty, type: $type) {
272
+ cartonId
273
+ }
274
+ }
275
+ `,
276
+ variables: { printQty: parseInt(printQty), type: 'inbound_carton_id' }
277
+ })
278
+
279
+ if (!response.errors) {
280
+ return response.data.generateCartonId
281
+ } else {
282
+ throw new Error('Unable to Generate Carton Id')
117
283
  }
118
284
  }
119
285
 
120
286
  stateChanged(state) {
121
- let cartonLabelSetting = state.dashboard[CARTON_LABEL_SETTING_KEY]
122
- this._cartonLabel = (cartonLabelSetting && cartonLabelSetting.board) || {}
287
+ let filters = [
288
+ { name: i18next.t(`label.normal`), value: 'default', labelId: CARTON_LABEL_SETTING_KEY },
289
+ { name: i18next.t(`label.print_by_sku`), value: 'bySku', labelId: CARTON_LABEL_BY_SKU_SETTING_KEY }
290
+ ]
291
+
292
+ this._filters = filters
293
+ .map(filter => {
294
+ let setting = state.dashboard[filter.labelId]
295
+ return { ...filter, board: setting?.board || null }
296
+ })
297
+ .filter(filter => filter.board)
123
298
  }
124
299
 
125
300
  _showToast({ type, message }) {
@@ -504,11 +504,14 @@ class WorksheetUnloadingReturn extends localize(i18next)(PageView) {
504
504
  }
505
505
 
506
506
  _openCartonLabelPrintPopup() {
507
- openPopup(html` <carton-label-popup .bizplaceName="${this._bizplace}"></carton-label-popup> `, {
508
- backdrop: true,
509
- size: 'small',
510
- title: i18next.t('title.carton_label')
511
- })
507
+ openPopup(
508
+ html` <carton-label-popup .fixedType="${'default'}" .bizplaceName="${this._bizplace}"></carton-label-popup> `,
509
+ {
510
+ backdrop: true,
511
+ size: 'small',
512
+ title: i18next.t('title.carton_label')
513
+ }
514
+ )
512
515
  }
513
516
 
514
517
  _showPutawayWorksheetPopup() {
@@ -8,30 +8,16 @@ import './pallet-label-popup'
8
8
  import './putaway-worksheet-generate-popup'
9
9
 
10
10
  import gql from 'graphql-tag'
11
- import {
12
- css,
13
- html
14
- } from 'lit-element'
11
+ import { css, html } from 'lit-element'
15
12
 
16
13
  import { getCodeByName } from '@things-factory/code-base'
17
14
  import { MultiColumnFormStyles } from '@things-factory/form-ui'
18
15
  import { getRenderer } from '@things-factory/grist-ui'
19
- import {
20
- i18next,
21
- localize
22
- } from '@things-factory/i18n-base'
16
+ import { i18next, localize } from '@things-factory/i18n-base'
23
17
  import { openPopup } from '@things-factory/layout-base'
24
- import {
25
- client,
26
- CustomAlert,
27
- navigate,
28
- PageView
29
- } from '@things-factory/shell'
18
+ import { client, CustomAlert, navigate, PageView } from '@things-factory/shell'
30
19
  import { CommonButtonStyles } from '@things-factory/styles'
31
- import {
32
- isMobileDevice,
33
- sleep
34
- } from '@things-factory/utils'
20
+ import { isMobileDevice, sleep } from '@things-factory/utils'
35
21
 
36
22
  import { fetchSettingRule } from '../../fetch-setting-value'
37
23
  import {
@@ -541,6 +527,7 @@ class WorksheetUnloading extends localize(i18next)(PageView) {
541
527
  type
542
528
  description
543
529
  }
530
+ manufactureDate
544
531
  batchId
545
532
  adjustedBatchId
546
533
  batchIdRef
@@ -584,20 +571,25 @@ class WorksheetUnloading extends localize(i18next)(PageView) {
584
571
  })
585
572
 
586
573
  this.data = {
587
- records: worksheetDetails.map(worksheetDetail => {
588
- const targetProduct = worksheetDetail.targetProduct
589
- return {
590
- ...worksheetDetail,
591
- ...worksheetDetail.targetProduct,
592
- initialBatchId: targetProduct.batchId,
593
- productSku: targetProduct.product.sku,
594
- productBrand: targetProduct.product.brand,
595
- hasBatchChanges: targetProduct && targetProduct.batchId !== targetProduct.initialBatchId ? false : true,
596
- isPalletized:
597
- targetProduct && targetProduct.palletQty && Number(targetProduct.palletQty) > 0 ? true : false,
598
- isLooseItem: worksheet.arrivalNotice.looseItem ? true : false
599
- }
600
- }).sort((a, b) => a.product.sku.localeCompare(b.product.sku))
574
+ records: worksheetDetails
575
+ .map(worksheetDetail => {
576
+ const targetProduct = worksheetDetail.targetProduct
577
+ return {
578
+ ...worksheetDetail,
579
+ ...worksheetDetail.targetProduct,
580
+ initialBatchId: targetProduct.batchId,
581
+ productSku: targetProduct.product.sku,
582
+ productBrand: targetProduct.product.brand,
583
+ hasBatchChanges: targetProduct && targetProduct.batchId !== targetProduct.initialBatchId ? false : true,
584
+ isPalletized:
585
+ targetProduct && targetProduct.palletQty && Number(targetProduct.palletQty) > 0 ? true : false,
586
+ isLooseItem: worksheet.arrivalNotice.looseItem ? true : false,
587
+ refNo: worksheet.arrivalNotice.refNo,
588
+ refNo2: worksheet.arrivalNotice.refNo2,
589
+ refNo3: worksheet.arrivalNotice.refNo3
590
+ }
591
+ })
592
+ .sort((a, b) => a.product.sku.localeCompare(b.product.sku))
601
593
  }
602
594
 
603
595
  const orderVass = worksheet.orderVass
@@ -611,7 +603,7 @@ class WorksheetUnloading extends localize(i18next)(PageView) {
611
603
  set: orderVas.set ? `Set ${orderVas.set}` : ''
612
604
  }
613
605
  })
614
- };
606
+ }
615
607
  }
616
608
 
617
609
  this._enableCartonLabel = await fetchSettingRule('enable-carton-label', partnerDomainId)
@@ -957,11 +949,14 @@ class WorksheetUnloading extends localize(i18next)(PageView) {
957
949
 
958
950
  async _openCartonLabelPrintPopup() {
959
951
  await sleep(1010)
960
- openPopup(html` <carton-label-popup .bizplaceName="${this._bizplace}"></carton-label-popup> `, {
961
- backdrop: true,
962
- size: 'small',
963
- title: i18next.t('title.carton_label')
964
- })
952
+ openPopup(
953
+ html` <carton-label-popup .bizplaceName="${this._bizplace}" .data="${this.data}"></carton-label-popup> `,
954
+ {
955
+ backdrop: true,
956
+ size: 'medium',
957
+ title: i18next.t('title.carton_label')
958
+ }
959
+ )
965
960
  }
966
961
 
967
962
  async _showPutawayWorksheetPopup() {
@@ -996,7 +991,7 @@ class WorksheetUnloading extends localize(i18next)(PageView) {
996
991
  )
997
992
  }
998
993
 
999
- //sort values
994
+ //sort values
1000
995
  _compareValues(key, order = 'asc') {
1001
996
  return function innerSort(a, b) {
1002
997
  if (!a.hasOwnProperty(key) || !b.hasOwnProperty(key)) {
@@ -1015,7 +1010,6 @@ class WorksheetUnloading extends localize(i18next)(PageView) {
1015
1010
  return order === 'desc' ? comparison * -1 : comparison
1016
1011
  }
1017
1012
  }
1018
-
1019
1013
  }
1020
1014
 
1021
1015
  window.customElements.define('worksheet-unloading', WorksheetUnloading)
@@ -10,25 +10,14 @@ import './proceed-edit-product-popup'
10
10
  import './view-product-changes-popup'
11
11
 
12
12
  import gql from 'graphql-tag'
13
- import {
14
- css,
15
- html
16
- } from 'lit-element'
13
+ import { css, html } from 'lit-element'
17
14
 
18
15
  import { getCodeByName } from '@things-factory/code-base'
19
16
  import { MultiColumnFormStyles } from '@things-factory/form-ui'
20
17
  import { getRenderer } from '@things-factory/grist-ui'
21
- import {
22
- i18next,
23
- localize
24
- } from '@things-factory/i18n-base'
18
+ import { i18next, localize } from '@things-factory/i18n-base'
25
19
  import { openPopup } from '@things-factory/layout-base'
26
- import {
27
- client,
28
- CustomAlert,
29
- navigate,
30
- PageView
31
- } from '@things-factory/shell'
20
+ import { client, CustomAlert, navigate, PageView } from '@things-factory/shell'
32
21
  import { CommonButtonStyles } from '@things-factory/styles'
33
22
  import { isMobileDevice } from '@things-factory/utils'
34
23
 
@@ -307,7 +296,8 @@ class ArrivalNoticeDetail extends localize(i18next)(PageView) {
307
296
  title: i18next.t('button.cancel'),
308
297
  action: this._cancelArrivalNotice.bind(this),
309
298
  ...CommonButtonStyles.cancel
310
- },{
299
+ },
300
+ {
311
301
  title: i18next.t('button.assign_warehouse'),
312
302
  action: this._assignBufferLocation.bind(this),
313
303
  ...CommonButtonStyles.warehouse
@@ -388,7 +378,11 @@ class ArrivalNoticeDetail extends localize(i18next)(PageView) {
388
378
  })
389
379
  }
390
380
 
391
- if (this._status === ORDER_STATUS.INTRANSIT.value || this._status === ORDER_STATUS.ARRIVED.value || this._status === ORDER_STATUS.READY_TO_UNLOAD.value) {
381
+ if (
382
+ this._status === ORDER_STATUS.INTRANSIT.value ||
383
+ this._status === ORDER_STATUS.ARRIVED.value ||
384
+ this._status === ORDER_STATUS.READY_TO_UNLOAD.value
385
+ ) {
392
386
  actions.push({
393
387
  title: i18next.t('button.cancel'),
394
388
  action: this._cancelArrivalNotice.bind(this),
@@ -1060,13 +1054,14 @@ class ArrivalNoticeDetail extends localize(i18next)(PageView) {
1060
1054
  this.setProductGristConfig()
1061
1055
  this.productData = {
1062
1056
  records: orderProducts
1063
- .map(record => {
1064
- return {
1065
- ...record,
1066
- productSku: record.product.sku,
1067
- productBrand: record.product.brand
1068
- }
1069
- }).sort((a, b) => a.product.sku.localeCompare(b.product.sku))
1057
+ .map(record => {
1058
+ return {
1059
+ ...record,
1060
+ productSku: record.product.sku,
1061
+ productBrand: record.product.brand
1062
+ }
1063
+ })
1064
+ .sort((a, b) => a.product.sku.localeCompare(b.product.sku))
1070
1065
  }
1071
1066
  this.vasData = {
1072
1067
  records: orderVass
@@ -1518,7 +1513,7 @@ class ArrivalNoticeDetail extends localize(i18next)(PageView) {
1518
1513
  })
1519
1514
 
1520
1515
  if (!result.value) return
1521
-
1516
+
1522
1517
  const response = await client.mutate({
1523
1518
  mutation: gql`
1524
1519
  mutation cancelArrivalNotice($name: String!) {
@@ -1641,11 +1636,14 @@ class ArrivalNoticeDetail extends localize(i18next)(PageView) {
1641
1636
  }
1642
1637
 
1643
1638
  _openCartonLabelPrintPopup() {
1644
- openPopup(html` <carton-label-popup .bizplaceName="${this._bizplaceName}"></carton-label-popup> `, {
1645
- backdrop: true,
1646
- size: 'small',
1647
- title: i18next.t('title.carton_label')
1648
- })
1639
+ openPopup(
1640
+ html` <carton-label-popup .fixedType="${'default'}" .bizplaceName="${this._bizplaceName}"></carton-label-popup> `,
1641
+ {
1642
+ backdrop: true,
1643
+ size: 'small',
1644
+ title: i18next.t('title.carton_label')
1645
+ }
1646
+ )
1649
1647
  }
1650
1648
 
1651
1649
  openEditProductPopup() {
@@ -1727,7 +1725,6 @@ class ArrivalNoticeDetail extends localize(i18next)(PageView) {
1727
1725
  })
1728
1726
  )
1729
1727
  }
1730
-
1731
1728
  }
1732
1729
 
1733
1730
  window.customElements.define('arrival-notice-detail', ArrivalNoticeDetail)