@things-factory/operato-wms 4.3.356 → 4.3.357
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/client/pages/components/select-cc-product-popup.js +321 -0
- package/client/pages/constants/order.js +15 -0
- package/client/pages/inventory-check/add-extra-inventory-popup.js +306 -0
- package/client/pages/inventory-check/check-inventory-popup.js +183 -167
- package/client/pages/inventory-check/create-cycle-count.js +292 -141
- package/client/pages/inventory-check/cycle-count-inventory-details-popup.js +282 -0
- package/client/pages/inventory-check/cycle-count-recheck-popup.js +129 -31
- package/client/pages/inventory-check/cycle-count-report.js +425 -306
- package/client/pages/inventory-check/cycle-count-review.js +742 -0
- package/client/pages/inventory-check/cycle-count-worksheet-list.js +476 -0
- package/client/pages/inventory-check/inspecting-product.js +954 -1029
- package/client/pages/inventory-check/inventory-check-detail.js +378 -0
- package/client/pages/inventory-check/inventory-check-list.js +35 -109
- package/client/pages/inventory-check/relocate-inventory-popup.js +222 -0
- package/client/pages/inventory-check/search-popup.js +1 -1
- package/client/pages/inventory-check/select-cc-location-popup.js +230 -0
- package/client/pages/inventory-check/worksheet-cycle-count.js +112 -90
- package/client/pages/outbound/route-label-popup.js +16 -0
- package/client/route.js +8 -0
- package/dist-server/graphql/resolvers/reports/cycle-count-report.js +244 -0
- package/dist-server/graphql/resolvers/reports/cycle-count-report.js.map +1 -0
- package/dist-server/graphql/resolvers/reports/index.js +2 -1
- package/dist-server/graphql/resolvers/reports/index.js.map +1 -1
- package/dist-server/graphql/types/reports/cycle-count-report-list.js +14 -0
- package/dist-server/graphql/types/reports/cycle-count-report-list.js.map +1 -0
- package/dist-server/graphql/types/reports/cycle-count-report.js +25 -0
- package/dist-server/graphql/types/reports/cycle-count-report.js.map +1 -0
- package/dist-server/graphql/types/reports/index.js +5 -0
- package/dist-server/graphql/types/reports/index.js.map +1 -1
- package/package.json +6 -6
- package/server/graphql/resolvers/reports/cycle-count-report.ts +267 -0
- package/server/graphql/resolvers/reports/index.ts +3 -4
- package/server/graphql/types/reports/cycle-count-report-list.ts +8 -0
- package/server/graphql/types/reports/cycle-count-report.ts +19 -0
- package/server/graphql/types/reports/index.ts +7 -8
- package/things-factory.config.js +8 -0
- package/translations/en.json +34 -0
- package/translations/ko.json +34 -0
- package/translations/ms.json +35 -1
- package/translations/zh.json +37 -3
|
@@ -0,0 +1,742 @@
|
|
|
1
|
+
import { MultiColumnFormStyles } from '@things-factory/form-ui'
|
|
2
|
+
import '@things-factory/grist-ui'
|
|
3
|
+
import { i18next, localize } from '@things-factory/i18n-base'
|
|
4
|
+
import { openPopup } from '@things-factory/layout-base'
|
|
5
|
+
import { client, CustomAlert, navigate, PageView } from '@things-factory/shell'
|
|
6
|
+
import { CommonButtonStyles } from '@things-factory/styles'
|
|
7
|
+
import { isMobileDevice } from '@things-factory/utils'
|
|
8
|
+
import gql from 'graphql-tag'
|
|
9
|
+
import { css, html } from 'lit-element'
|
|
10
|
+
import { ORDER_STATUS, WORKSHEET_STATUS, WORKSHEET_TYPE } from '../constants'
|
|
11
|
+
import { fetchSettingRule } from '../../fetch-setting-value'
|
|
12
|
+
import './cycle-count-recheck-popup'
|
|
13
|
+
|
|
14
|
+
class CycleCountReview extends localize(i18next)(PageView) {
|
|
15
|
+
static get properties() {
|
|
16
|
+
return {
|
|
17
|
+
_worksheetNo: String,
|
|
18
|
+
_reportStatus: String,
|
|
19
|
+
_cycleCountNo: String,
|
|
20
|
+
_enableCartonLabel: Boolean,
|
|
21
|
+
_pageSettings: Object,
|
|
22
|
+
cycleCountType: String,
|
|
23
|
+
customerId: String,
|
|
24
|
+
inventoryAccuracy: String,
|
|
25
|
+
config: Object,
|
|
26
|
+
data: Object
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
static get styles() {
|
|
31
|
+
return [
|
|
32
|
+
MultiColumnFormStyles,
|
|
33
|
+
css`
|
|
34
|
+
:host {
|
|
35
|
+
display: flex;
|
|
36
|
+
flex-direction: column;
|
|
37
|
+
overflow-x: auto;
|
|
38
|
+
}
|
|
39
|
+
.form-container {
|
|
40
|
+
display: flex;
|
|
41
|
+
}
|
|
42
|
+
.form-container > form {
|
|
43
|
+
flex: 1;
|
|
44
|
+
}
|
|
45
|
+
.grist {
|
|
46
|
+
background-color: var(--main-section-background-color);
|
|
47
|
+
display: flex;
|
|
48
|
+
flex-direction: column;
|
|
49
|
+
flex: 1;
|
|
50
|
+
overflow-y: auto;
|
|
51
|
+
}
|
|
52
|
+
data-grist {
|
|
53
|
+
overflow-y: hidden;
|
|
54
|
+
flex: 1;
|
|
55
|
+
}
|
|
56
|
+
h2 {
|
|
57
|
+
padding: var(--subtitle-padding);
|
|
58
|
+
font: var(--subtitle-font);
|
|
59
|
+
color: var(--subtitle-text-color);
|
|
60
|
+
border-bottom: var(--subtitle-border-bottom);
|
|
61
|
+
}
|
|
62
|
+
.grist h2 {
|
|
63
|
+
margin: var(--grist-title-margin);
|
|
64
|
+
border: var(--grist-title-border);
|
|
65
|
+
font: var(--grist-title-font);
|
|
66
|
+
color: var(--secondary-color);
|
|
67
|
+
}
|
|
68
|
+
.grist h2 mwc-icon {
|
|
69
|
+
vertical-align: middle;
|
|
70
|
+
margin: var(--grist-title-icon-margin);
|
|
71
|
+
font-size: var(--grist-title-icon-size);
|
|
72
|
+
color: var(--grist-title-icon-color);
|
|
73
|
+
}
|
|
74
|
+
h2 + data-grist {
|
|
75
|
+
padding-top: var(--grist-title-with-grid-padding);
|
|
76
|
+
}
|
|
77
|
+
`
|
|
78
|
+
]
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
get context() {
|
|
82
|
+
var actions = [
|
|
83
|
+
{
|
|
84
|
+
title: i18next.t('button.back'),
|
|
85
|
+
action: () => navigate('cycle_count_worksheet_list'),
|
|
86
|
+
...CommonButtonStyles.back
|
|
87
|
+
}
|
|
88
|
+
]
|
|
89
|
+
|
|
90
|
+
if (this._reportStatus === ORDER_STATUS.PENDING_REVIEW.value) {
|
|
91
|
+
if (this.isUserBelongsDomain) {
|
|
92
|
+
actions.push({
|
|
93
|
+
title: i18next.t('button.adjust_inventory'),
|
|
94
|
+
action: this._adjustInventory.bind(this),
|
|
95
|
+
...CommonButtonStyles.edit
|
|
96
|
+
})
|
|
97
|
+
|
|
98
|
+
if (this.cycleCountType === WORKSHEET_TYPE.CYCLE_COUNT.value) {
|
|
99
|
+
actions.push({
|
|
100
|
+
title: i18next.t('button.reject'),
|
|
101
|
+
action: this.openCycleCountRecheckPopup.bind(this),
|
|
102
|
+
...CommonButtonStyles.reject
|
|
103
|
+
})
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
return {
|
|
109
|
+
title: i18next.t('title.cycle_count_worksheet_review'),
|
|
110
|
+
actions,
|
|
111
|
+
printable: {
|
|
112
|
+
accept: ['preview'],
|
|
113
|
+
content: this
|
|
114
|
+
},
|
|
115
|
+
exportable: {
|
|
116
|
+
name: this._cycleCountNo,
|
|
117
|
+
data: this._exportableData.bind(this)
|
|
118
|
+
},
|
|
119
|
+
help: 'operato-wms/inventory-check/cycle-count-review'
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
render() {
|
|
124
|
+
return html`
|
|
125
|
+
<div class="form-container">
|
|
126
|
+
<form class="multi-column-form">
|
|
127
|
+
<fieldset>
|
|
128
|
+
<legend>${i18next.t('title.cycle_count')}</legend>
|
|
129
|
+
<label>${i18next.t('label.company')}</label>
|
|
130
|
+
<input name="bizplace" readonly />
|
|
131
|
+
<label>${i18next.t('label.inventory_check_no')}</label>
|
|
132
|
+
<input name="cycleCountNo" readonly />
|
|
133
|
+
<label>${i18next.t('label.execute_date')}</label>
|
|
134
|
+
<input name="executionDate" readonly />
|
|
135
|
+
<label>${i18next.t('label.inventory_accuracy')}</label>
|
|
136
|
+
<input name="inventoryAccuracy" value="${this.inventoryAccuracy ? this.inventoryAccuracy : ''}" readonly />
|
|
137
|
+
<label>${i18next.t('label.status')}</label>
|
|
138
|
+
<select name="status" disabled>
|
|
139
|
+
${Object.keys(ORDER_STATUS).map(
|
|
140
|
+
key => html`
|
|
141
|
+
<option value="${ORDER_STATUS[key].value}">${i18next.t(`label.${ORDER_STATUS[key].name}`)}</option>
|
|
142
|
+
`
|
|
143
|
+
)}
|
|
144
|
+
</select>
|
|
145
|
+
<label>${i18next.t('label.cycle_count_task_no')}</label>
|
|
146
|
+
<input name="checkCount" readonly />
|
|
147
|
+
</fieldset>
|
|
148
|
+
</form>
|
|
149
|
+
</div>
|
|
150
|
+
<div class="grist">
|
|
151
|
+
<h2><mwc-icon>list_alt</mwc-icon>${i18next.t('title.inventory')}</h2>
|
|
152
|
+
<data-grist
|
|
153
|
+
id="grist"
|
|
154
|
+
.mode=${isMobileDevice() ? 'LIST' : 'GRID'}
|
|
155
|
+
.config=${this.config}
|
|
156
|
+
.fetchHandler="${this.fetchWorksheetWithPagination.bind(this)}"
|
|
157
|
+
></data-grist>
|
|
158
|
+
</div>
|
|
159
|
+
`
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
constructor() {
|
|
163
|
+
super()
|
|
164
|
+
this._enableCartonLabel = false
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
async pageUpdated(changes) {
|
|
168
|
+
if (this.active && (changes.resourceId || this._worksheetNo)) {
|
|
169
|
+
if (changes.resourceId) {
|
|
170
|
+
this._worksheetNo = changes.resourceId
|
|
171
|
+
}
|
|
172
|
+
this.grist.fetch()
|
|
173
|
+
await this.fetchWorksheet()
|
|
174
|
+
this.updateContext()
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
async pageInitialized() {
|
|
179
|
+
const enableCarton = fetchSettingRule('enable-carton-label')
|
|
180
|
+
|
|
181
|
+
this._pageSettings = {
|
|
182
|
+
...this._pageSettings,
|
|
183
|
+
enableCarton: (await enableCarton) || false
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
this.isUserBelongsDomain = await this._checkUserBelongsDomain()
|
|
187
|
+
this.config = {
|
|
188
|
+
rows: {
|
|
189
|
+
appendable: false,
|
|
190
|
+
classifier: (record, rowIndex) => {
|
|
191
|
+
return {
|
|
192
|
+
emphasized:
|
|
193
|
+
record.status === WORKSHEET_STATUS.NOT_TALLY.value || record.status === WORKSHEET_STATUS.ADJUSTED.value
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
},
|
|
197
|
+
list: {
|
|
198
|
+
fields: [
|
|
199
|
+
'batchId',
|
|
200
|
+
'inspectedBatchNo',
|
|
201
|
+
'palletId',
|
|
202
|
+
'product',
|
|
203
|
+
'packingType',
|
|
204
|
+
'inspectedStatus',
|
|
205
|
+
'inspectedLocation',
|
|
206
|
+
'inspectedQty',
|
|
207
|
+
'inspectedUomValue',
|
|
208
|
+
'status'
|
|
209
|
+
]
|
|
210
|
+
},
|
|
211
|
+
columns: [
|
|
212
|
+
{ type: 'gutter', gutterName: 'sequence' },
|
|
213
|
+
{
|
|
214
|
+
type: 'string',
|
|
215
|
+
name: 'cartonId',
|
|
216
|
+
header: i18next.t('field.carton_id'),
|
|
217
|
+
width: 130
|
|
218
|
+
},
|
|
219
|
+
{
|
|
220
|
+
type: 'string',
|
|
221
|
+
name: 'palletId',
|
|
222
|
+
header: i18next.t('field.lot_id'),
|
|
223
|
+
width: 100
|
|
224
|
+
},
|
|
225
|
+
{
|
|
226
|
+
type: 'string',
|
|
227
|
+
name: 'sku',
|
|
228
|
+
header: i18next.t('field.sku'),
|
|
229
|
+
width: 110
|
|
230
|
+
},
|
|
231
|
+
{
|
|
232
|
+
type: 'string',
|
|
233
|
+
name: 'productName',
|
|
234
|
+
header: i18next.t('field.product'),
|
|
235
|
+
width: 350
|
|
236
|
+
},
|
|
237
|
+
{
|
|
238
|
+
type: 'string',
|
|
239
|
+
name: 'brand',
|
|
240
|
+
header: i18next.t('field.brand'),
|
|
241
|
+
width: 100
|
|
242
|
+
},
|
|
243
|
+
{
|
|
244
|
+
type: 'string',
|
|
245
|
+
name: 'packingType',
|
|
246
|
+
header: i18next.t('field.packing_type'),
|
|
247
|
+
width: 100
|
|
248
|
+
},
|
|
249
|
+
{
|
|
250
|
+
type: 'string',
|
|
251
|
+
name: 'inspectedStatus',
|
|
252
|
+
header: i18next.t('field.inspected_status'),
|
|
253
|
+
width: 130
|
|
254
|
+
},
|
|
255
|
+
{
|
|
256
|
+
type: 'string',
|
|
257
|
+
name: 'batchId',
|
|
258
|
+
header: i18next.t('field.system_batch_no'),
|
|
259
|
+
width: 100
|
|
260
|
+
},
|
|
261
|
+
{
|
|
262
|
+
type: 'string',
|
|
263
|
+
name: 'inspectedBatchNo',
|
|
264
|
+
header: i18next.t('field.inspected_batch_no'),
|
|
265
|
+
width: 140
|
|
266
|
+
},
|
|
267
|
+
{
|
|
268
|
+
type: 'string',
|
|
269
|
+
name: 'locationName',
|
|
270
|
+
header: i18next.t('field.system_location'),
|
|
271
|
+
width: 120
|
|
272
|
+
},
|
|
273
|
+
{
|
|
274
|
+
type: 'string',
|
|
275
|
+
name: 'inspectedLocation',
|
|
276
|
+
header: i18next.t('field.inspected_location'),
|
|
277
|
+
width: 120
|
|
278
|
+
},
|
|
279
|
+
{
|
|
280
|
+
type: 'integer',
|
|
281
|
+
name: 'qty',
|
|
282
|
+
header: i18next.t('field.system_qty'),
|
|
283
|
+
width: 120
|
|
284
|
+
},
|
|
285
|
+
{
|
|
286
|
+
type: 'integer',
|
|
287
|
+
name: 'inspectedQty',
|
|
288
|
+
header: i18next.t('field.inspected_qty'),
|
|
289
|
+
width: 100
|
|
290
|
+
},
|
|
291
|
+
{
|
|
292
|
+
type: 'float',
|
|
293
|
+
name: 'uomValue',
|
|
294
|
+
header: i18next.t('field.system_uom_value'),
|
|
295
|
+
width: 100
|
|
296
|
+
},
|
|
297
|
+
{
|
|
298
|
+
type: 'float',
|
|
299
|
+
name: 'inspectedUomValue',
|
|
300
|
+
header: i18next.t('field.inspected_uom_value'),
|
|
301
|
+
width: 100
|
|
302
|
+
},
|
|
303
|
+
{
|
|
304
|
+
type: 'string',
|
|
305
|
+
name: 'uom',
|
|
306
|
+
header: i18next.t('field.uom'),
|
|
307
|
+
width: 80
|
|
308
|
+
},
|
|
309
|
+
{
|
|
310
|
+
type: 'string',
|
|
311
|
+
name: 'status',
|
|
312
|
+
header: i18next.t('field.status'),
|
|
313
|
+
width: 100
|
|
314
|
+
}
|
|
315
|
+
]
|
|
316
|
+
}
|
|
317
|
+
this._updateConfig()
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
_updateConfig() {
|
|
321
|
+
const isCartonEnabled = this._pageSettings?.enableCarton
|
|
322
|
+
this.config.columns = this.config.columns.filter(column => {
|
|
323
|
+
if (isCartonEnabled == true) {
|
|
324
|
+
return column.name !== 'palletId'
|
|
325
|
+
} else {
|
|
326
|
+
return column.name !== 'cartonId'
|
|
327
|
+
}
|
|
328
|
+
})
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
get form() {
|
|
332
|
+
return this.shadowRoot.querySelector('form')
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
get grist() {
|
|
336
|
+
return this.shadowRoot.querySelector('data-grist')
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
async fetchWorksheet() {
|
|
340
|
+
if (!this._worksheetNo) return
|
|
341
|
+
const response = await client.query({
|
|
342
|
+
query: gql`
|
|
343
|
+
query worksheetWithPagination($name: String!, $pagination: Pagination) {
|
|
344
|
+
worksheetWithPagination(name: $name, pagination: $pagination) {
|
|
345
|
+
worksheet {
|
|
346
|
+
type
|
|
347
|
+
status
|
|
348
|
+
inventoryCheck {
|
|
349
|
+
name
|
|
350
|
+
executionDate
|
|
351
|
+
status
|
|
352
|
+
}
|
|
353
|
+
bizplace {
|
|
354
|
+
id
|
|
355
|
+
name
|
|
356
|
+
domain {
|
|
357
|
+
id
|
|
358
|
+
name
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
}
|
|
362
|
+
worksheetDetails {
|
|
363
|
+
name
|
|
364
|
+
status
|
|
365
|
+
description
|
|
366
|
+
targetInventoryCheckItem {
|
|
367
|
+
status
|
|
368
|
+
id
|
|
369
|
+
inspectedBatchNo
|
|
370
|
+
inspectedQty
|
|
371
|
+
inspectedUomValue
|
|
372
|
+
inspectedLocation {
|
|
373
|
+
id
|
|
374
|
+
name
|
|
375
|
+
description
|
|
376
|
+
}
|
|
377
|
+
product {
|
|
378
|
+
sku
|
|
379
|
+
name
|
|
380
|
+
brand
|
|
381
|
+
description
|
|
382
|
+
}
|
|
383
|
+
productDetail {
|
|
384
|
+
packingType
|
|
385
|
+
uom
|
|
386
|
+
}
|
|
387
|
+
inventory {
|
|
388
|
+
cartonId
|
|
389
|
+
palletId
|
|
390
|
+
batchId
|
|
391
|
+
packingType
|
|
392
|
+
qty
|
|
393
|
+
uomValue
|
|
394
|
+
uom
|
|
395
|
+
location {
|
|
396
|
+
id
|
|
397
|
+
name
|
|
398
|
+
description
|
|
399
|
+
}
|
|
400
|
+
product {
|
|
401
|
+
sku
|
|
402
|
+
name
|
|
403
|
+
description
|
|
404
|
+
}
|
|
405
|
+
}
|
|
406
|
+
}
|
|
407
|
+
}
|
|
408
|
+
total
|
|
409
|
+
}
|
|
410
|
+
}
|
|
411
|
+
`,
|
|
412
|
+
variables: { name: this._worksheetNo, pagination: {} }
|
|
413
|
+
})
|
|
414
|
+
|
|
415
|
+
if (!response.errors) {
|
|
416
|
+
const worksheetDetails = response.data.worksheetWithPagination.worksheetDetails
|
|
417
|
+
const tallyInv = worksheetDetails.filter(wd => wd.status === WORKSHEET_STATUS.DONE.value)
|
|
418
|
+
const notTallyInv = worksheetDetails.filter(wd => wd.status === WORKSHEET_STATUS.NOT_TALLY.value)
|
|
419
|
+
const adjustedInv = worksheetDetails.filter(wd => wd.status === WORKSHEET_STATUS.ADJUSTED.value)
|
|
420
|
+
|
|
421
|
+
const accuracyInv =
|
|
422
|
+
(tallyInv.length / (tallyInv.length + (notTallyInv.length ? notTallyInv.length : adjustedInv.length))) * 100 +
|
|
423
|
+
`%`
|
|
424
|
+
|
|
425
|
+
this.inventoryAccuracy = accuracyInv
|
|
426
|
+
}
|
|
427
|
+
}
|
|
428
|
+
|
|
429
|
+
async fetchWorksheetWithPagination({ page, limit }) {
|
|
430
|
+
if (!this._worksheetNo) return
|
|
431
|
+
const response = await client.query({
|
|
432
|
+
query: gql`
|
|
433
|
+
query worksheetWithPagination($name: String!, $pagination: Pagination) {
|
|
434
|
+
worksheetWithPagination(name: $name, pagination: $pagination) {
|
|
435
|
+
worksheet {
|
|
436
|
+
type
|
|
437
|
+
status
|
|
438
|
+
checkCount
|
|
439
|
+
inventoryCheck {
|
|
440
|
+
name
|
|
441
|
+
executionDate
|
|
442
|
+
status
|
|
443
|
+
}
|
|
444
|
+
bizplace {
|
|
445
|
+
id
|
|
446
|
+
name
|
|
447
|
+
domain {
|
|
448
|
+
id
|
|
449
|
+
name
|
|
450
|
+
}
|
|
451
|
+
}
|
|
452
|
+
}
|
|
453
|
+
worksheetDetails {
|
|
454
|
+
name
|
|
455
|
+
status
|
|
456
|
+
description
|
|
457
|
+
targetInventoryCheckItem {
|
|
458
|
+
status
|
|
459
|
+
id
|
|
460
|
+
originBatchNo
|
|
461
|
+
inspectedBatchNo
|
|
462
|
+
originQty
|
|
463
|
+
inspectedQty
|
|
464
|
+
originUomValue
|
|
465
|
+
inspectedUomValue
|
|
466
|
+
originLocation {
|
|
467
|
+
id
|
|
468
|
+
name
|
|
469
|
+
description
|
|
470
|
+
}
|
|
471
|
+
product {
|
|
472
|
+
sku
|
|
473
|
+
name
|
|
474
|
+
brand
|
|
475
|
+
description
|
|
476
|
+
}
|
|
477
|
+
productDetail {
|
|
478
|
+
id
|
|
479
|
+
packingType
|
|
480
|
+
uom
|
|
481
|
+
}
|
|
482
|
+
inspectedLocation {
|
|
483
|
+
id
|
|
484
|
+
name
|
|
485
|
+
description
|
|
486
|
+
}
|
|
487
|
+
inventory {
|
|
488
|
+
cartonId
|
|
489
|
+
palletId
|
|
490
|
+
packingType
|
|
491
|
+
uom
|
|
492
|
+
product {
|
|
493
|
+
id
|
|
494
|
+
sku
|
|
495
|
+
name
|
|
496
|
+
brand
|
|
497
|
+
description
|
|
498
|
+
}
|
|
499
|
+
}
|
|
500
|
+
}
|
|
501
|
+
}
|
|
502
|
+
total
|
|
503
|
+
}
|
|
504
|
+
}
|
|
505
|
+
`,
|
|
506
|
+
variables: { name: this._worksheetNo, pagination: { page, limit } }
|
|
507
|
+
})
|
|
508
|
+
|
|
509
|
+
if (!response.errors) {
|
|
510
|
+
const worksheet = response.data.worksheetWithPagination.worksheet
|
|
511
|
+
const partnerDomainId = worksheet.bizplace?.domain.id
|
|
512
|
+
this.cycleCountType = worksheet.type
|
|
513
|
+
this.customerId = worksheet.bizplace.id
|
|
514
|
+
const worksheetDetails = response.data.worksheetWithPagination.worksheetDetails
|
|
515
|
+
const total = response.data.worksheetWithPagination.total
|
|
516
|
+
|
|
517
|
+
this._enableCartonLabel = await fetchSettingRule('enable-carton-label', partnerDomainId)
|
|
518
|
+
this._reportStatus = worksheet.inventoryCheck.status
|
|
519
|
+
this._cycleCountNo = (worksheet.inventoryCheck && worksheet.inventoryCheck.name) || ''
|
|
520
|
+
|
|
521
|
+
this._fillupForm({
|
|
522
|
+
...worksheet,
|
|
523
|
+
cycleCountNo: worksheet.inventoryCheck.name,
|
|
524
|
+
executionDate: worksheet.inventoryCheck.executionDate,
|
|
525
|
+
status: this._reportStatus
|
|
526
|
+
})
|
|
527
|
+
const records = worksheetDetails
|
|
528
|
+
.map(worksheetDetail => {
|
|
529
|
+
const targetItem = worksheetDetail.targetInventoryCheckItem
|
|
530
|
+
const inventoryItem = targetItem?.inventory
|
|
531
|
+
|
|
532
|
+
return {
|
|
533
|
+
...inventoryItem,
|
|
534
|
+
name: worksheetDetail.name,
|
|
535
|
+
sku: inventoryItem?.product.sku ? inventoryItem.product.sku : targetItem.product.sku,
|
|
536
|
+
brand: inventoryItem?.product.brand ? inventoryItem.product.brand : targetItem.product.brand,
|
|
537
|
+
description: worksheetDetail.description,
|
|
538
|
+
productName:
|
|
539
|
+
targetItem.product.name + `(` + targetItem.product.description + `)` ||
|
|
540
|
+
inventoryItem.product.name + `(` + inventoryItem.product.description + `)`,
|
|
541
|
+
locationName: targetItem.originLocation?.name,
|
|
542
|
+
status: worksheetDetail.status,
|
|
543
|
+
cartonId: inventoryItem?.cartonId,
|
|
544
|
+
palletId: inventoryItem?.palletId,
|
|
545
|
+
batchId: targetItem.originBatchNo,
|
|
546
|
+
inspectedBatchNo: targetItem.inspectedBatchNo,
|
|
547
|
+
qty: targetItem?.originQty,
|
|
548
|
+
inspectedQty: targetItem?.inspectedQty,
|
|
549
|
+
uomValue: targetItem?.originUomValue,
|
|
550
|
+
inspectedUomValue: targetItem?.inspectedUomValue,
|
|
551
|
+
uom: inventoryItem?.uom ? inventoryItem?.uom : targetItem.productDetail?.uom,
|
|
552
|
+
inspectedLocation: targetItem.inspectedLocation?.name,
|
|
553
|
+
packingType: inventoryItem?.packingType ? inventoryItem.packingType : targetItem.packingType,
|
|
554
|
+
inspectedStatus: targetItem.status,
|
|
555
|
+
orderInventoryId: targetItem.id
|
|
556
|
+
}
|
|
557
|
+
})
|
|
558
|
+
.sort(this._compareValues('status', 'desc'))
|
|
559
|
+
|
|
560
|
+
if (this._enableCartonLabel) {
|
|
561
|
+
const groupedRecords = {}
|
|
562
|
+
let groupedTotal = 0
|
|
563
|
+
|
|
564
|
+
records.forEach(record => {
|
|
565
|
+
const groupKey = `${record.cartonId || ''}-${record.sku || ''}-${record.batchId || ''}-${
|
|
566
|
+
record.locationName || ''
|
|
567
|
+
}`
|
|
568
|
+
|
|
569
|
+
if (!groupedRecords[groupKey]) {
|
|
570
|
+
groupedRecords[groupKey] = { ...record, count: 1 }
|
|
571
|
+
groupedTotal++
|
|
572
|
+
} else {
|
|
573
|
+
groupedRecords[groupKey].qty += record.qty || 0
|
|
574
|
+
groupedRecords[groupKey].inspectedQty += record.inspectedQty || 0
|
|
575
|
+
groupedRecords[groupKey].uomValue += record.uomValue || 0
|
|
576
|
+
groupedRecords[groupKey].inspectedUomValue += record.inspectedUomValue || 0
|
|
577
|
+
groupedRecords[groupKey].count += 1
|
|
578
|
+
}
|
|
579
|
+
})
|
|
580
|
+
|
|
581
|
+
const groupedResults = Object.values(groupedRecords)
|
|
582
|
+
|
|
583
|
+
this.updateContext()
|
|
584
|
+
return { records: groupedResults, total: groupedTotal }
|
|
585
|
+
} else {
|
|
586
|
+
this.updateContext()
|
|
587
|
+
return { records, total }
|
|
588
|
+
}
|
|
589
|
+
}
|
|
590
|
+
}
|
|
591
|
+
|
|
592
|
+
_fillupForm(data) {
|
|
593
|
+
for (let key in data) {
|
|
594
|
+
Array.from(this.form.querySelectorAll('input, select')).forEach(field => {
|
|
595
|
+
if (field.name === key && field.type === 'checkbox') {
|
|
596
|
+
field.checked = data[key]
|
|
597
|
+
} else if (field.name === key) {
|
|
598
|
+
if (data[key] instanceof Object) {
|
|
599
|
+
const objectData = data[key]
|
|
600
|
+
field.value = `${objectData.name} ${objectData.description ? `(${objectData.description})` : ''}`
|
|
601
|
+
} else {
|
|
602
|
+
field.value = data[key]
|
|
603
|
+
}
|
|
604
|
+
}
|
|
605
|
+
})
|
|
606
|
+
}
|
|
607
|
+
}
|
|
608
|
+
|
|
609
|
+
_compareValues(key, order = 'asc') {
|
|
610
|
+
return function innerSort(a, b) {
|
|
611
|
+
if (!a.hasOwnProperty(key) || !b.hasOwnProperty(key)) {
|
|
612
|
+
return 0
|
|
613
|
+
}
|
|
614
|
+
|
|
615
|
+
const varA = typeof a[key] === 'string' ? a[key].toUpperCase() : a[key]
|
|
616
|
+
const varB = typeof b[key] === 'string' ? b[key].toUpperCase() : b[key]
|
|
617
|
+
|
|
618
|
+
let comparison = 0
|
|
619
|
+
if (varA > varB) {
|
|
620
|
+
comparison = 1
|
|
621
|
+
} else if (varA < varB) {
|
|
622
|
+
comparison = -1
|
|
623
|
+
}
|
|
624
|
+
return order === 'desc' ? comparison * -1 : comparison
|
|
625
|
+
}
|
|
626
|
+
}
|
|
627
|
+
|
|
628
|
+
async _adjustInventory() {
|
|
629
|
+
try {
|
|
630
|
+
const result = await CustomAlert({
|
|
631
|
+
title: i18next.t('title.are_you_sure'),
|
|
632
|
+
text: i18next.t('text.inventory_adjustment'),
|
|
633
|
+
confirmButton: { text: i18next.t('button.confirm') },
|
|
634
|
+
cancelButton: { text: i18next.t('button.cancel') }
|
|
635
|
+
})
|
|
636
|
+
|
|
637
|
+
if (!result.value) {
|
|
638
|
+
return
|
|
639
|
+
}
|
|
640
|
+
|
|
641
|
+
const response = await client.mutate({
|
|
642
|
+
mutation: gql`
|
|
643
|
+
mutation cycleCountAdjustment($worksheetNo: String!, $cycleCountNo: String!) {
|
|
644
|
+
cycleCountAdjustment(worksheetNo: $worksheetNo, cycleCountNo: $cycleCountNo)
|
|
645
|
+
}
|
|
646
|
+
`,
|
|
647
|
+
variables: { worksheetNo: this._worksheetNo, cycleCountNo: this._cycleCountNo }
|
|
648
|
+
})
|
|
649
|
+
if (!response.errors) {
|
|
650
|
+
this._showToast({ message: i18next.t('text.inventory_has_been_adjusted') })
|
|
651
|
+
await this.grist.fetch()
|
|
652
|
+
this.updateContext()
|
|
653
|
+
navigate(`worksheet_cycle_count/${this._worksheetNo}`)
|
|
654
|
+
}
|
|
655
|
+
} catch (e) {
|
|
656
|
+
this._showToast(e)
|
|
657
|
+
}
|
|
658
|
+
}
|
|
659
|
+
|
|
660
|
+
openCycleCountRecheckPopup() {
|
|
661
|
+
openPopup(
|
|
662
|
+
html`
|
|
663
|
+
<cycle-count-recheck-popup
|
|
664
|
+
.cycleCountNo="${this._cycleCountNo}"
|
|
665
|
+
.customerId="${this.customerId}"
|
|
666
|
+
.enableCartonLabel="${this._enableCartonLabel}"
|
|
667
|
+
@completed="${() => this.grist.fetch()}"
|
|
668
|
+
></cycle-count-recheck-popup>
|
|
669
|
+
`,
|
|
670
|
+
{
|
|
671
|
+
backdrop: true,
|
|
672
|
+
size: 'large',
|
|
673
|
+
title: i18next.t('title.cycle_count_recheck')
|
|
674
|
+
}
|
|
675
|
+
)
|
|
676
|
+
}
|
|
677
|
+
|
|
678
|
+
async _checkUserBelongsDomain() {
|
|
679
|
+
try {
|
|
680
|
+
const response = await client.query({
|
|
681
|
+
query: gql`
|
|
682
|
+
query {
|
|
683
|
+
checkUserBelongsDomain
|
|
684
|
+
}
|
|
685
|
+
`
|
|
686
|
+
})
|
|
687
|
+
|
|
688
|
+
if (!response.errors) {
|
|
689
|
+
return response.data.checkUserBelongsDomain
|
|
690
|
+
}
|
|
691
|
+
} catch (e) {
|
|
692
|
+
this._showToast(e)
|
|
693
|
+
}
|
|
694
|
+
}
|
|
695
|
+
|
|
696
|
+
async _exportableData() {
|
|
697
|
+
try {
|
|
698
|
+
let data = []
|
|
699
|
+
|
|
700
|
+
var headerSetting = [
|
|
701
|
+
{ header: i18next.t('field.system_batch_no'), key: 'batchId', width: 25, type: 'string' },
|
|
702
|
+
{ header: i18next.t('field.inspected_batch_no'), key: 'inspectedBatchNo', width: 25, type: 'string' },
|
|
703
|
+
{ header: i18next.t('field.lot_id'), key: 'palletId', width: 25, type: 'string' },
|
|
704
|
+
{ header: i18next.t('field.product'), key: 'productName', width: 60, type: 'string' },
|
|
705
|
+
{ header: i18next.t('field.packing_type'), key: 'packingType', width: 20, type: 'string' },
|
|
706
|
+
{ header: i18next.t('field.inspected_status'), key: 'inspectedStatus', width: 20, type: 'string' },
|
|
707
|
+
{ header: i18next.t('field.system_location'), key: 'locationName', width: 20, type: 'string' },
|
|
708
|
+
{ header: i18next.t('field.inspected_location'), key: 'inspectedLocation', width: 20, type: 'string' },
|
|
709
|
+
{ header: i18next.t('field.system_qty'), key: 'qty', width: 20, type: 'string' },
|
|
710
|
+
{ header: i18next.t('field.inspected_qty'), key: 'inspectedQty', width: 20, type: 'string' },
|
|
711
|
+
{ header: i18next.t('field.system_uom_value'), key: 'uomValue', width: 20, type: 'string' },
|
|
712
|
+
{
|
|
713
|
+
header: i18next.t('field.inspected_uom_value'),
|
|
714
|
+
key: 'inspectedUomValue',
|
|
715
|
+
width: 20,
|
|
716
|
+
type: 'string'
|
|
717
|
+
},
|
|
718
|
+
{ header: i18next.t('field.uom'), key: 'uom', width: 20, type: 'string' },
|
|
719
|
+
{ header: i18next.t('field.status'), key: 'status', width: 20, type: 'string' }
|
|
720
|
+
]
|
|
721
|
+
|
|
722
|
+
data = (await this.fetchWorksheetWithPagination({ page: 1, limit: 999999 })).records
|
|
723
|
+
|
|
724
|
+
return { header: headerSetting, data }
|
|
725
|
+
} catch (e) {
|
|
726
|
+
this._showToast(e)
|
|
727
|
+
}
|
|
728
|
+
}
|
|
729
|
+
|
|
730
|
+
_showToast({ type, message }) {
|
|
731
|
+
document.dispatchEvent(
|
|
732
|
+
new CustomEvent('notify', {
|
|
733
|
+
detail: {
|
|
734
|
+
type,
|
|
735
|
+
message
|
|
736
|
+
}
|
|
737
|
+
})
|
|
738
|
+
)
|
|
739
|
+
}
|
|
740
|
+
}
|
|
741
|
+
|
|
742
|
+
window.customElements.define('cycle-count-review', CycleCountReview)
|