@things-factory/operato-wms 4.0.9 → 4.0.13

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 (160) hide show
  1. package/client/pages/adjustment/transfer-inventory.js +368 -165
  2. package/client/pages/billing/claim-chit/claim-chit-list.js +7 -6
  3. package/client/pages/bulk-operation/bulk-operation.js +316 -0
  4. package/client/pages/bulk-operation/validate-ro-popup.js +445 -0
  5. package/client/pages/components/select-product-popup.js +15 -2
  6. package/client/pages/constants/inventory.js +1 -0
  7. package/client/pages/constants/location.js +33 -6
  8. package/client/pages/constants/order.js +10 -0
  9. package/client/pages/constants/worksheet.js +2 -2
  10. package/client/pages/inbound/inbound-worksheet.js +78 -9
  11. package/client/pages/inbound/putaway-product.js +214 -139
  12. package/client/pages/inbound/putaway-worksheet-generate-popup.js +24 -2
  13. package/client/pages/inbound/unload-product.js +149 -76
  14. package/client/pages/inbound/worksheet-putaway-return.js +22 -5
  15. package/client/pages/inbound/worksheet-putaway.js +21 -8
  16. package/client/pages/inbound/worksheet-unloading-return.js +22 -5
  17. package/client/pages/inbound/worksheet-unloading.js +8 -0
  18. package/client/pages/inventory/inventory-adjustment-approval.js +11 -19
  19. package/client/pages/inventory/inventory-adjustment.js +136 -101
  20. package/client/pages/inventory/inventory-by-product-detail.js +3 -5
  21. package/client/pages/inventory/inventory-by-product.js +8 -0
  22. package/client/pages/inventory/inventory-history-by-pallet.js +12 -5
  23. package/client/pages/inventory/inventory-history.js +14 -5
  24. package/client/pages/inventory/onhand-inventory.js +11 -2
  25. package/client/pages/inventory-check/create-cycle-count.js +12 -6
  26. package/client/pages/inventory-check/cycle-count-report.js +8 -0
  27. package/client/pages/inventory-check/inspecting-product.js +146 -80
  28. package/client/pages/inventory-check/worksheet-cycle-count.js +14 -0
  29. package/client/pages/manifest/create-loading-manifest.js +314 -0
  30. package/client/pages/manifest/dispatcher-verification-popup.js +86 -0
  31. package/client/pages/manifest/loading-manifest-detail.js +345 -0
  32. package/client/pages/manifest/loading-manifest-list.js +305 -0
  33. package/client/pages/master/location-list.js +58 -17
  34. package/client/pages/master/product/product-detail-bizplace-setting-popup.js +2 -2
  35. package/client/pages/master/product/product-details-popup.js +2 -2
  36. package/client/pages/master/product/product-list.js +5 -5
  37. package/client/pages/order/arrival-notice/arrival-notice-detail.js +134 -115
  38. package/client/pages/order/arrival-notice/arrival-notice-list.js +87 -6
  39. package/client/pages/order/arrival-notice/arrival-notice-requests.js +83 -6
  40. package/client/pages/order/arrival-notice/assign-buffer-location.js +8 -1
  41. package/client/pages/order/arrival-notice/check-arrived-notice.js +9 -1
  42. package/client/pages/order/arrival-notice/create-arrival-notice.js +38 -3
  43. package/client/pages/order/arrival-notice/duplicate-arrival-notice.js +290 -25
  44. package/client/pages/order/arrival-notice/edit-product-popup.js +36 -5
  45. package/client/pages/order/arrival-notice/receive-arrival-notice.js +8 -1
  46. package/client/pages/order/goods-received-note/received-note-list.js +138 -6
  47. package/client/pages/order/release-order/b2b/b2b-order-list.js +45 -5
  48. package/client/pages/order/release-order/b2b/b2b-order-requests.js +52 -12
  49. package/client/pages/order/release-order/b2c/b2c-order-requests.js +244 -24
  50. package/client/pages/order/release-order/bulk-print-packing-list.js +23 -0
  51. package/client/pages/order/release-order/create-release-order.js +55 -8
  52. package/client/pages/order/release-order/receive-release-order-request.js +35 -24
  53. package/client/pages/order/release-order/release-extra-product-popup.js +204 -63
  54. package/client/pages/order/release-order/release-order-detail.js +301 -74
  55. package/client/pages/order/return-order/check-return-order.js +9 -1
  56. package/client/pages/order/return-order/create-return-order.js +14 -2
  57. package/client/pages/order/return-order/receive-return-order-requests.js +9 -1
  58. package/client/pages/order/return-order/return-order-detail.js +15 -6
  59. package/client/pages/order/return-order/return-order-inventory-popup.js +7 -0
  60. package/client/pages/order/reverse-kitting-order/reverse-kitting-order-detail.js +124 -59
  61. package/client/pages/order/reverse-kitting-order/reverse-kitting-order-list.js +1 -6
  62. package/client/pages/order/reverse-kitting-order/reverse-kitting-pallet-label-popup.js +239 -0
  63. package/client/pages/order/transport-order/delivery-order-list.js +102 -59
  64. package/client/pages/outbound/inventory-assign-popup.js +23 -6
  65. package/client/pages/outbound/inventory-auto-assign-popup.js +22 -6
  66. package/client/pages/outbound/loading-product.js +4 -1
  67. package/client/pages/outbound/merged-outbound-worksheet.js +43 -1
  68. package/client/pages/outbound/packing-product.js +4 -1
  69. package/client/pages/outbound/packing-worksheet-list.js +39 -1
  70. package/client/pages/outbound/picking-product.js +803 -431
  71. package/client/pages/outbound/picking-replacement-popup.js +1 -1
  72. package/client/pages/outbound/serial-number-popup.js +280 -0
  73. package/client/pages/outbound/single-outbound-worksheet.js +47 -1
  74. package/client/pages/outbound/worksheet-batch-picking.js +22 -8
  75. package/client/pages/outbound/worksheet-loading.js +22 -5
  76. package/client/pages/outbound/worksheet-packing.js +8 -0
  77. package/client/pages/outbound/worksheet-picking.js +62 -8
  78. package/client/pages/outbound/worksheet-return.js +9 -1
  79. package/client/pages/outbound/worksheet-sorting.js +9 -1
  80. package/client/pages/report/custom-elccl/elccl-inventory-report.js +31 -30
  81. package/client/pages/report/custom-elccl/elccl-inventory-summary-report.js +23 -26
  82. package/client/pages/report/inventory-pallet-storage-report.js +11 -10
  83. package/client/pages/report/inventory-report.js +41 -43
  84. package/client/pages/report/inventory-summary-report.js +25 -28
  85. package/client/pages/report/product-label-report.js +401 -0
  86. package/client/pages/support/inventory-comparison.js +296 -0
  87. package/client/pages/vas/print-product-label.js +298 -132
  88. package/client/pages/vas/reverse-kitting/execute-reverse-kitting.js +38 -23
  89. package/client/pages/vas/reverse-kitting/popup-combination-sets.js +98 -15
  90. package/client/pages/vas/reverse-kitting/popup-reverse-kitting-template.js +129 -21
  91. package/client/pages/vas/vas-pallet-label-popup.js +5 -8
  92. package/client/route.js +28 -0
  93. package/dist-server/graphql/resolvers/custom/elccl/elccl-inventory-history-report.js +1 -1
  94. package/dist-server/graphql/resolvers/custom/elccl/elccl-inventory-history-report.js.map +1 -1
  95. package/dist-server/graphql/resolvers/custom/elccl/elccl-inventory-history-summary-report.js +64 -54
  96. package/dist-server/graphql/resolvers/custom/elccl/elccl-inventory-history-summary-report.js.map +1 -1
  97. package/dist-server/graphql/resolvers/extra/add-release-good-products.js +34 -9
  98. package/dist-server/graphql/resolvers/extra/add-release-good-products.js.map +1 -1
  99. package/dist-server/graphql/resolvers/index.js +5 -1
  100. package/dist-server/graphql/resolvers/index.js.map +1 -1
  101. package/dist-server/graphql/resolvers/inventory-comparison/index.js +6 -0
  102. package/dist-server/graphql/resolvers/inventory-comparison/index.js.map +1 -0
  103. package/dist-server/graphql/resolvers/inventory-comparison/inventory-comparison-list.js +78 -0
  104. package/dist-server/graphql/resolvers/inventory-comparison/inventory-comparison-list.js.map +1 -0
  105. package/dist-server/graphql/resolvers/reports/index.js +2 -1
  106. package/dist-server/graphql/resolvers/reports/index.js.map +1 -1
  107. package/dist-server/graphql/resolvers/reports/product-label-report.js +56 -0
  108. package/dist-server/graphql/resolvers/reports/product-label-report.js.map +1 -0
  109. package/dist-server/graphql/resolvers/shipping-provider/index.js +6 -0
  110. package/dist-server/graphql/resolvers/shipping-provider/index.js.map +1 -0
  111. package/dist-server/graphql/resolvers/shipping-provider/shipping-providers.js +20 -0
  112. package/dist-server/graphql/resolvers/shipping-provider/shipping-providers.js.map +1 -0
  113. package/dist-server/graphql/types/custom/elccl/elccl-inventory-report.js +1 -1
  114. package/dist-server/graphql/types/index.js +8 -2
  115. package/dist-server/graphql/types/index.js.map +1 -1
  116. package/dist-server/graphql/types/inventory-comparison/index.js +13 -0
  117. package/dist-server/graphql/types/inventory-comparison/index.js.map +1 -0
  118. package/dist-server/graphql/types/inventory-comparison/inventory-comparison-list.js +14 -0
  119. package/dist-server/graphql/types/inventory-comparison/inventory-comparison-list.js.map +1 -0
  120. package/dist-server/graphql/types/inventory-comparison/inventory-comparison.js +18 -0
  121. package/dist-server/graphql/types/inventory-comparison/inventory-comparison.js.map +1 -0
  122. package/dist-server/graphql/types/reports/index.js +6 -1
  123. package/dist-server/graphql/types/reports/index.js.map +1 -1
  124. package/dist-server/graphql/types/reports/product-label-report-list.js +14 -0
  125. package/dist-server/graphql/types/reports/product-label-report-list.js.map +1 -0
  126. package/dist-server/graphql/types/reports/product-label-report.js +16 -0
  127. package/dist-server/graphql/types/reports/product-label-report.js.map +1 -0
  128. package/dist-server/graphql/types/shipping-provider/index.js +10 -0
  129. package/dist-server/graphql/types/shipping-provider/index.js.map +1 -0
  130. package/dist-server/graphql/types/shipping-provider/shipping-provider-list.js +13 -0
  131. package/dist-server/graphql/types/shipping-provider/shipping-provider-list.js.map +1 -0
  132. package/dist-server/graphql/types/shipping-provider/shipping-provider.js +13 -0
  133. package/dist-server/graphql/types/shipping-provider/shipping-provider.js.map +1 -0
  134. package/package.json +65 -65
  135. package/server/graphql/resolvers/custom/elccl/elccl-inventory-history-report.ts +4 -2
  136. package/server/graphql/resolvers/custom/elccl/elccl-inventory-history-summary-report.ts +75 -65
  137. package/server/graphql/resolvers/extra/add-release-good-products.ts +57 -15
  138. package/server/graphql/resolvers/index.ts +5 -1
  139. package/server/graphql/resolvers/inventory-comparison/index.ts +5 -0
  140. package/server/graphql/resolvers/inventory-comparison/inventory-comparison-list.ts +99 -0
  141. package/server/graphql/resolvers/reports/index.ts +3 -1
  142. package/server/graphql/resolvers/reports/product-label-report.ts +56 -0
  143. package/server/graphql/resolvers/shipping-provider/index.ts +5 -0
  144. package/server/graphql/resolvers/shipping-provider/shipping-providers.ts +20 -0
  145. package/server/graphql/types/custom/elccl/elccl-inventory-report.ts +1 -1
  146. package/server/graphql/types/index.ts +8 -2
  147. package/server/graphql/types/inventory-comparison/index.ts +11 -0
  148. package/server/graphql/types/inventory-comparison/inventory-comparison-list.ts +8 -0
  149. package/server/graphql/types/inventory-comparison/inventory-comparison.ts +12 -0
  150. package/server/graphql/types/reports/index.ts +6 -1
  151. package/server/graphql/types/reports/product-label-report-list.ts +8 -0
  152. package/server/graphql/types/reports/product-label-report.ts +10 -0
  153. package/server/graphql/types/shipping-provider/index.ts +8 -0
  154. package/server/graphql/types/shipping-provider/shipping-provider-list.ts +7 -0
  155. package/server/graphql/types/shipping-provider/shipping-provider.ts +7 -0
  156. package/things-factory.config.js +30 -0
  157. package/translations/en.json +91 -11
  158. package/translations/ko.json +109 -11
  159. package/translations/ms.json +111 -12
  160. package/translations/zh.json +123 -26
@@ -0,0 +1,345 @@
1
+ import '@things-factory/grist-ui'
2
+ import './dispatcher-verification-popup'
3
+
4
+ import gql from 'graphql-tag'
5
+ import { css, html } from 'lit-element'
6
+
7
+ import { GhostPrint } from '@operato/ghost-print'
8
+ import { MultiColumnFormStyles } from '@things-factory/form-ui'
9
+ import { i18next, localize } from '@things-factory/i18n-base'
10
+ import { openPopup } from '@things-factory/layout-base'
11
+ import { client, navigate, PageView } from '@things-factory/shell'
12
+ import { CommonButtonStyles } from '@things-factory/styles'
13
+ import { isMobileDevice } from '@things-factory/utils'
14
+
15
+ import { MANIFEST_STATUS } from '../constants'
16
+
17
+ class LoadingManifestDetail extends localize(i18next)(PageView) {
18
+ static get styles() {
19
+ return [
20
+ MultiColumnFormStyles,
21
+ css`
22
+ :host {
23
+ display: flex;
24
+ flex-direction: column;
25
+ overflow-x: auto;
26
+ }
27
+ .container {
28
+ flex: 1;
29
+ display: flex;
30
+ overflow-y: auto;
31
+ min-height: 50vh;
32
+ }
33
+ .grist {
34
+ background-color: var(--main-section-background-color);
35
+ display: flex;
36
+ flex-direction: column;
37
+ flex: 1;
38
+ overflow-y: auto;
39
+ }
40
+ data-grist {
41
+ overflow-y: hidden;
42
+ flex: 1;
43
+ }
44
+ h2 {
45
+ padding: var(--subtitle-padding);
46
+ font: var(--subtitle-font);
47
+ color: var(--subtitle-text-color);
48
+ border-bottom: var(--subtitle-border-bottom);
49
+ }
50
+ .grist h2 {
51
+ margin: var(--grist-title-margin);
52
+ border: var(--grist-title-border);
53
+ font: var(--grist-title-font);
54
+ color: var(--secondary-color);
55
+ }
56
+
57
+ .grist h2 mwc-icon {
58
+ vertical-align: middle;
59
+ margin: var(--grist-title-icon-margin);
60
+ font-size: var(--grist-title-icon-size);
61
+ color: var(--grist-title-icon-color);
62
+ }
63
+
64
+ h2 + data-grist {
65
+ padding-top: var(--grist-title-with-grid-padding);
66
+ }
67
+ `
68
+ ]
69
+ }
70
+
71
+ static get properties() {
72
+ return {
73
+ shippingData: Object,
74
+ shippingGristConfig: Object,
75
+ _manifestNo: String,
76
+ _status: String
77
+ }
78
+ }
79
+
80
+ get context() {
81
+ var actions = [
82
+ {
83
+ title: i18next.t('button.back'),
84
+ action: () => navigate('loading_manifest_list'),
85
+ ...CommonButtonStyles.back
86
+ },
87
+ {
88
+ title: i18next.t('button.print'),
89
+ action: this._printManifest.bind(this),
90
+ ...CommonButtonStyles.label
91
+ }
92
+ ]
93
+
94
+ if (this._status == MANIFEST_STATUS.OPEN.value) {
95
+ actions.push({
96
+ title: i18next.t('button.dispatch'),
97
+ action: this._openDispatcherVerificationPopup.bind(this),
98
+ ...CommonButtonStyles.load
99
+ })
100
+ }
101
+
102
+ return {
103
+ title: i18next.t('title.manifest'),
104
+ actions
105
+ }
106
+ }
107
+
108
+ get manifestForm() {
109
+ return this.shadowRoot.querySelector('form[name=manifest]')
110
+ }
111
+
112
+ render() {
113
+ return html`
114
+ <div class="form-container">
115
+ <form name="manifest" class="multi-column-form">
116
+ <fieldset>
117
+ <legend>${i18next.t('title.manifest_no')}: ${this._manifestNo}</legend>
118
+ <label>${i18next.t('label.shipping_provider')}</label>
119
+ <input name="shippingProvider" readonly />
120
+
121
+ <label>${i18next.t('label.dispatcher_name')}</label>
122
+ <input name="dispatcherName" readonly />
123
+
124
+ <label>${i18next.t('label.dispatcher_identity')}</label>
125
+ <input name="dispatcherIdentity" readonly />
126
+
127
+ <label>${i18next.t('label.dispatch_at')}</label>
128
+ <input name="dispatchedAt" type="datetime-local" readonly />
129
+
130
+ <label>${i18next.t('label.total_tracking_no')}</label>
131
+ <input name="totalTrackingNo" readonly />
132
+
133
+ <label>${i18next.t('label.status')}</label>
134
+ <input name="status" readonly />
135
+ </fieldset>
136
+ </form>
137
+ </div>
138
+
139
+ <div class="container">
140
+ <div class="grist">
141
+ <h2><mwc-icon>list_alt</mwc-icon>${i18next.t('title.manifest_items')}</h2>
142
+
143
+ <data-grist
144
+ .mode=${isMobileDevice() ? 'LIST' : 'GRID'}
145
+ .config=${this.shippingGristConfig}
146
+ .data=${this.shippingData}
147
+ ></data-grist>
148
+ </div>
149
+ </div>
150
+ `
151
+ }
152
+
153
+ pageInitialized() {
154
+ this.shippingGristConfig = {
155
+ list: { fields: ['refNo', 'trackingNo', 'dispatchmentStatus'] },
156
+ pagination: { infinite: true },
157
+ columns: [
158
+ { type: 'gutter', gutterName: 'sequence' },
159
+ {
160
+ type: 'string',
161
+ name: 'refNo',
162
+ label: true,
163
+ header: i18next.t('field.order_no'),
164
+ width: 200
165
+ },
166
+ {
167
+ type: 'string',
168
+ name: 'trackingNo',
169
+ label: true,
170
+ header: i18next.t('field.tracking_no'),
171
+ width: 200
172
+ },
173
+ {
174
+ type: 'string',
175
+ name: 'attentionTo',
176
+ label: true,
177
+ header: i18next.t('field.delivery_to'),
178
+ width: 150
179
+ },
180
+ {
181
+ type: 'string',
182
+ name: 'phone',
183
+ label: true,
184
+ header: i18next.t('field.phone'),
185
+ width: 150
186
+ },
187
+ {
188
+ type: 'string',
189
+ name: 'deliveryAddress',
190
+ label: true,
191
+ header: i18next.t('field.delivery_address'),
192
+ width: 250
193
+ },
194
+ {
195
+ type: 'string',
196
+ name: 'postalCode',
197
+ label: true,
198
+ header: i18next.t('field.postal_code'),
199
+ width: 120
200
+ },
201
+ {
202
+ type: 'string',
203
+ name: 'city',
204
+ label: true,
205
+ header: i18next.t('field.city'),
206
+ width: 120
207
+ },
208
+ {
209
+ type: 'string',
210
+ name: 'dispatchmentStatus',
211
+ label: true,
212
+ header: i18next.t('field.status'),
213
+ width: 150
214
+ }
215
+ ]
216
+ }
217
+ }
218
+
219
+ async pageUpdated(changes, lifecycle, before) {
220
+ if (this.active) {
221
+ this._manifestNo = changes.resourceId || this._manifestNo || ''
222
+ await this._fetchManifestDetail()
223
+ this.updateContext()
224
+ }
225
+ }
226
+
227
+ async _fetchManifestDetail() {
228
+ if (!this._manifestNo) return
229
+
230
+ const response = await client.query({
231
+ query: gql`
232
+ query manifest($name: String!) {
233
+ manifest(name: $name) {
234
+ id
235
+ name
236
+ dispatchedAt
237
+ dispatcherName
238
+ dispatcherIdentity
239
+ status
240
+ shippingProvider
241
+ trackingNos {
242
+ trackingNo
243
+ deliveryAddress
244
+ attentionTo
245
+ phone
246
+ postalCode
247
+ city
248
+ refNo
249
+ dispatchmentStatus
250
+ }
251
+ }
252
+ }
253
+ `,
254
+ variables: { name: this._manifestNo }
255
+ })
256
+
257
+ if (!response.errors) {
258
+ const manifest = response.data.manifest
259
+
260
+ this._status = manifest.status
261
+ this._fillupForm(this.manifestForm, { ...manifest, totalTrackingNo: manifest.trackingNos?.length })
262
+ this.shippingData = { records: manifest.trackingNos }
263
+ this.updateContext()
264
+ }
265
+ }
266
+
267
+ _openDispatcherVerificationPopup() {
268
+ openPopup(
269
+ html`
270
+ <dispatcher-verification-popup
271
+ @dispatch="${e => {
272
+ this._dispatchManifest(e.detail)
273
+ }}"
274
+ ></dispatcher-verification-popup>
275
+ `,
276
+ {
277
+ size: 'medium',
278
+ title: `${i18next.t('title.dispatcher_verification')}`
279
+ }
280
+ )
281
+ }
282
+
283
+ async _dispatchManifest(patch) {
284
+ const response = await client.mutate({
285
+ mutation: gql`
286
+ mutation dispatchManifest($name: String!, $patch: ManifestPatch!) {
287
+ dispatchManifest(name: $name, patch: $patch) {
288
+ id
289
+ name
290
+ }
291
+ }
292
+ `,
293
+ variables: { name: this._manifestNo, patch }
294
+ })
295
+
296
+ if (!response.errors) {
297
+ await this._fetchManifestDetail()
298
+ this._showToast({ message: i18next.t('text.manifest_has_been_dispatched_and_closed') })
299
+ }
300
+ }
301
+
302
+ _printManifest() {
303
+ GhostPrint.print({
304
+ src: `/view_manifest/${this._manifestNo}`,
305
+ pending: 1000,
306
+ onfinish: () => {
307
+ this._showToast({ message: i18next.t('text.document_has_been_generated') })
308
+ }
309
+ })
310
+ }
311
+
312
+ _fillupForm(form, data) {
313
+ for (let key in data) {
314
+ Array.from(form.querySelectorAll('input, textarea, select')).forEach(field => {
315
+ if (field.name === key && field.type === 'checkbox') {
316
+ field.checked = data[key]
317
+ } else if (field.name === key && field.type === 'datetime-local') {
318
+ if (data[key]) {
319
+ const datetime = Number(data[key])
320
+ const timezoneOffset = new Date(datetime).getTimezoneOffset() * 60000
321
+ field.value = new Date(datetime - timezoneOffset).toISOString().slice(0, -1)
322
+ } else {
323
+ field.value = data[key]
324
+ }
325
+ } else if (field.name === key) {
326
+ field.value = data[key]
327
+ }
328
+ })
329
+ }
330
+ }
331
+
332
+ _showToast({ type, message }) {
333
+ document.dispatchEvent(
334
+ new CustomEvent('notify', {
335
+ detail: {
336
+ type,
337
+ message,
338
+ option: { timer: 1000 }
339
+ }
340
+ })
341
+ )
342
+ }
343
+ }
344
+
345
+ customElements.define('loading-manifest-detail', LoadingManifestDetail)
@@ -0,0 +1,305 @@
1
+ import '@things-factory/form-ui'
2
+ import '@things-factory/grist-ui'
3
+
4
+ import gql from 'graphql-tag'
5
+ import { css, html } from 'lit-element'
6
+
7
+ import { getCodeByName } from '@things-factory/code-base'
8
+ import { i18next, localize } from '@things-factory/i18n-base'
9
+ import { client, navigate, PageView } from '@things-factory/shell'
10
+ import { ScrollbarStyles } from '@things-factory/styles'
11
+ import { isMobileDevice } from '@things-factory/utils'
12
+
13
+ class LoadingManifestList extends localize(i18next)(PageView) {
14
+ static get styles() {
15
+ return [
16
+ ScrollbarStyles,
17
+ css`
18
+ :host {
19
+ display: flex;
20
+ flex-direction: column;
21
+ overflow: hidden;
22
+ }
23
+
24
+ search-form {
25
+ overflow: visible;
26
+ }
27
+
28
+ data-grist {
29
+ overflow-y: auto;
30
+ flex: 1;
31
+ }
32
+ `
33
+ ]
34
+ }
35
+
36
+ static get properties() {
37
+ return {
38
+ _searchFields: Array,
39
+ config: Object,
40
+ data: Object
41
+ }
42
+ }
43
+
44
+ get context() {
45
+ return {
46
+ title: i18next.t('title.manifest_list'),
47
+ exportable: {
48
+ name: i18next.t('title.manifest_list'),
49
+ data: this._exportableData.bind(this)
50
+ }
51
+ }
52
+ }
53
+
54
+ get _fromDateInput() {
55
+ return this.searchForm.shadowRoot.querySelector('input[name=fromDate]')
56
+ }
57
+
58
+ get _toDateInput() {
59
+ return this.searchForm.shadowRoot.querySelector('input[name=toDate]')
60
+ }
61
+
62
+ get searchForm() {
63
+ return this.shadowRoot.querySelector('search-form')
64
+ }
65
+
66
+ get dataGrist() {
67
+ return this.shadowRoot.querySelector('data-grist')
68
+ }
69
+
70
+ render() {
71
+ return html`
72
+ <search-form id="search-form" .fields=${this._searchFields} @submit=${e => this.dataGrist.fetch()}></search-form>
73
+
74
+ <data-grist
75
+ .mode=${isMobileDevice() ? 'LIST' : 'GRID'}
76
+ .config=${this.config}
77
+ .fetchHandler="${this.fetchHandler.bind(this)}"
78
+ ></data-grist>
79
+ `
80
+ }
81
+
82
+ pageUpdated(changes, lifecycle) {
83
+ if (this.active) {
84
+ this.dataGrist.fetch()
85
+ }
86
+ }
87
+
88
+ async pageInitialized() {
89
+ const manifestStatus = await getCodeByName('MANIFEST_STATUS')
90
+ this._searchFields = [
91
+ {
92
+ label: i18next.t('field.manifest_no'),
93
+ name: 'name',
94
+ type: 'text',
95
+ props: { searchOper: 'i_like' }
96
+ },
97
+ {
98
+ label: i18next.t('field.shipping_provider'),
99
+ name: 'shippingProvider',
100
+ type: 'text',
101
+ props: { searchOper: 'i_like' }
102
+ },
103
+ {
104
+ label: i18next.t('field.from'),
105
+ name: 'fromDate',
106
+ type: 'date',
107
+ props: {
108
+ searchOper: 'eq'
109
+ },
110
+ value: (() => {
111
+ let date = new Date()
112
+ date.setMonth(date.getMonth() - 6)
113
+ return date.toISOString().split('T')[0]
114
+ })(),
115
+ handlers: { change: this._modifyDateRange.bind(this) }
116
+ },
117
+ {
118
+ label: i18next.t('field.to'),
119
+ name: 'toDate',
120
+ type: 'date',
121
+ props: {
122
+ searchOper: 'eq',
123
+ min: (() => {
124
+ let date = new Date()
125
+ date.setMonth(date.getMonth() - 6)
126
+ return date.toISOString().split('T')[0]
127
+ })()
128
+ },
129
+ value: new Date().toISOString().split('T')[0]
130
+ },
131
+ {
132
+ label: i18next.t('field.status'),
133
+ name: 'status',
134
+ type: 'select',
135
+ options: [
136
+ { value: '' },
137
+ ...manifestStatus.map(status => {
138
+ return {
139
+ name: i18next.t(`label.${status.description}`),
140
+ value: status.name
141
+ }
142
+ })
143
+ ],
144
+ props: { searchOper: 'eq' }
145
+ }
146
+ ]
147
+
148
+ this.config = {
149
+ list: {
150
+ fields: ['name', 'shippingProvider', 'dispatchedAt', 'status', 'createdAt', 'updatedAt', 'creator']
151
+ },
152
+ rows: { appendable: false, selectable: { multiple: true } },
153
+ columns: [
154
+ { type: 'gutter', gutterName: 'sequence' },
155
+ { type: 'gutter', gutterName: 'row-selector', multiple: true },
156
+ {
157
+ type: 'gutter',
158
+ gutterName: 'button',
159
+ icon: 'reorder',
160
+ handlers: {
161
+ click: (columns, data, column, record, rowIndex) => {
162
+ navigate(`loading_manifest_detail/${record.name}`)
163
+ }
164
+ }
165
+ },
166
+ {
167
+ type: 'string',
168
+ name: 'name',
169
+ header: i18next.t('field.manifest_no'),
170
+ label: true,
171
+ sortable: true,
172
+ width: 180
173
+ },
174
+ {
175
+ type: 'string',
176
+ name: 'shippingProvider',
177
+ header: i18next.t('field.shipping_provider'),
178
+ label: true,
179
+ sortable: true,
180
+ width: 150
181
+ },
182
+ {
183
+ type: 'datetime',
184
+ name: 'dispatchedAt',
185
+ header: i18next.t('field.dispatch_at'),
186
+ label: true,
187
+ sortable: true,
188
+ width: 150
189
+ },
190
+ {
191
+ type: 'string',
192
+ name: 'status',
193
+ header: i18next.t('field.status'),
194
+ label: true,
195
+ sortable: true,
196
+ width: 170
197
+ },
198
+ {
199
+ type: 'datetime',
200
+ name: 'createdAt',
201
+ header: i18next.t('field.created_at'),
202
+ label: true,
203
+ sortable: true,
204
+ width: 160
205
+ },
206
+ {
207
+ type: 'object',
208
+ name: 'creator',
209
+ header: i18next.t('field.created_by'),
210
+ label: true,
211
+ sortable: true,
212
+ width: 200
213
+ }
214
+ ]
215
+ }
216
+ }
217
+
218
+ async fetchHandler({ page, limit, sorters = [{ name: 'createdAt', desc: true }] }) {
219
+ const response = await client.query({
220
+ query: gql`
221
+ query manifests($filters: [Filter], $pagination: Pagination, $sortings: [Sorting]) {
222
+ manifests(filters: $filters, pagination: $pagination, sortings: $sortings) {
223
+ items {
224
+ id
225
+ name
226
+ shippingProvider
227
+ dispatchedAt
228
+ status
229
+ createdAt
230
+ creator {
231
+ id
232
+ name
233
+ description
234
+ }
235
+ }
236
+ total
237
+ }
238
+ }
239
+ `,
240
+ variables: { filters: this.searchForm.queryFilters, pagination: { page, limit }, sortings: sorters }
241
+ })
242
+
243
+ if (!response.errors) {
244
+ return {
245
+ total: response.data.manifests.total || 0,
246
+ records: response.data.manifests.items || []
247
+ }
248
+ }
249
+ }
250
+
251
+ _modifyDateRange(e) {
252
+ const fromDate = e.currentTarget.value
253
+
254
+ if (this._toDateInput.value < fromDate) this._toDateInput.value = fromDate
255
+
256
+ let min = new Date(fromDate)
257
+ let today = new Date()
258
+ today.setHours(0, 0, 0, 0)
259
+
260
+ min = min.toISOString().split('T')[0]
261
+
262
+ this._toDateInput.min = min
263
+ }
264
+
265
+ get _columns() {
266
+ return this.config.columns
267
+ }
268
+
269
+ async _exportableData() {
270
+ try {
271
+ let data = []
272
+
273
+ var headerSetting = [
274
+ { header: i18next.t('field.manifest_no'), key: 'name', width: 25, type: 'string' },
275
+ { header: i18next.t('field.shipping_provider'), key: 'shippingProvider', width: 25, type: 'string' },
276
+ { header: i18next.t('field.dispatch_at'), key: 'dispatchedAt', width: 25, type: 'date' },
277
+ { header: i18next.t('field.status'), key: 'status', width: 25, type: 'string' },
278
+ { header: i18next.t('field.created_at'), key: 'createdAt', width: 30, type: 'date' },
279
+ { header: i18next.t('field.created_by'), key: 'createdBy', width: 25, type: 'string' }
280
+ ]
281
+
282
+ if (this.dataGrist.selected && this.dataGrist.selected.length > 0) {
283
+ data = this.dataGrist.selected.map(record => {
284
+ return {
285
+ ...record,
286
+ createdBy: record.creator.name
287
+ }
288
+ })
289
+ } else {
290
+ data = (await this.fetchHandler({ page: 1, limit: 9999999 })).records.map(record => {
291
+ return {
292
+ ...record,
293
+ createdBy: record.creator.name
294
+ }
295
+ })
296
+ }
297
+
298
+ return { header: headerSetting, data }
299
+ } catch (e) {
300
+ this._showToast(e)
301
+ }
302
+ }
303
+ }
304
+
305
+ customElements.define('loading-manifest-list', LoadingManifestList)