@things-factory/operato-wms 4.3.0-alpha.1 → 4.3.0
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/constants/index.js +1 -0
- package/client/constants/order.js +14 -0
- package/client/pages/constants/index.js +1 -0
- package/client/pages/constants/setting.js +1 -0
- package/client/pages/constants/tote.js +14 -0
- package/client/pages/inbound/unload-product.js +9 -5
- package/client/pages/inventory/inventory-adjustment-approval.js +24 -9
- package/client/pages/inventory/inventory-adjustment.js +79 -13
- package/client/pages/master/product/product-list.js +1 -1
- package/client/pages/master/tote-list.js +740 -0
- package/client/pages/order/arrival-notice/arrival-notice-detail.js +0 -2
- package/client/pages/order/arrival-notice/receive-arrival-notice.js +0 -2
- package/client/pages/order/draft-release-good/draft-release-good-detail.js +1163 -0
- package/client/pages/order/draft-release-good/draft-release-good-list.js +546 -0
- package/client/pages/order/goods-received-note/customer-received-note.js +3 -0
- package/client/pages/order/goods-received-note/received-note-detail.js +3 -0
- package/client/pages/order/release-order/b2c/b2c-order-requests.js +21 -30
- package/client/pages/order/release-order/bulk-print-packing-list.js +4 -0
- package/client/pages/order/release-order/receive-release-order-request.js +0 -2
- package/client/pages/order/release-order/release-order-detail.js +44 -26
- package/client/pages/order/return-order/receive-return-order-requests.js +0 -2
- package/client/pages/order/transfer-order/receive-transfer-order-request.js +1 -1
- package/client/pages/order/transport-order/print-delivery-note.js +0 -1
- package/client/pages/order/transport-order/view-delivery-note.js +1 -1
- package/client/pages/order/vas-order/receive-vas-order.js +0 -2
- package/client/pages/outbound/inventory-assign-popup.js +7 -2
- package/client/pages/outbound/inventory-auto-assign-popup.js +2 -1
- package/client/pages/outbound/loading-product.js +35 -3
- package/client/pages/outbound/order-remark-popup.js +112 -0
- package/client/pages/outbound/packing-product.js +38 -5
- package/client/pages/outbound/packing-worksheet-list.js +15 -0
- package/client/pages/outbound/picking-product.js +142 -10
- package/client/pages/outbound/single-outbound-worksheet.js +10 -22
- package/client/pages/outbound/sorting-product.js +72 -12
- package/client/pages/outbound/tote-popup.js +461 -0
- package/client/pages/outbound/worksheet-batch-picking.js +9 -2
- package/client/pages/outbound/worksheet-packing.js +7 -2
- package/client/pages/outbound/worksheet-picking.js +9 -2
- package/client/pages/report/inventory-summary-report.js +8 -0
- package/client/pages/report/outbound-order-details-report.js +18 -0
- package/client/pages/vas/print-product-label.js +15 -6
- package/client/route.js +12 -0
- package/dist-server/entities/index.js +2 -1
- package/dist-server/entities/index.js.map +1 -1
- package/dist-server/entities/warehouse-bizplace-onhand-inventory.js +168 -0
- package/dist-server/entities/warehouse-bizplace-onhand-inventory.js.map +1 -0
- package/dist-server/graphql/index.js +1 -5
- package/dist-server/graphql/index.js.map +1 -1
- package/dist-server/graphql/resolvers/board-setting/board-settings.js +2 -1
- package/dist-server/graphql/resolvers/board-setting/board-settings.js.map +1 -1
- package/dist-server/graphql/resolvers/index.js +4 -7
- package/dist-server/graphql/resolvers/index.js.map +1 -1
- package/dist-server/graphql/resolvers/reports/outbound-order-details-report.js +3 -1
- package/dist-server/graphql/resolvers/reports/outbound-order-details-report.js.map +1 -1
- package/dist-server/graphql/resolvers/warehouse-inventory-adjustment/index.js +6 -0
- package/dist-server/graphql/resolvers/warehouse-inventory-adjustment/index.js.map +1 -0
- package/dist-server/graphql/resolvers/warehouse-inventory-adjustment/warehouse-intentory-adjustment.js +58 -0
- package/dist-server/graphql/resolvers/warehouse-inventory-adjustment/warehouse-intentory-adjustment.js.map +1 -0
- package/dist-server/graphql/types/index.js +5 -8
- package/dist-server/graphql/types/index.js.map +1 -1
- package/dist-server/graphql/types/reports/outbound-order-details-report.js +2 -0
- package/dist-server/graphql/types/reports/outbound-order-details-report.js.map +1 -1
- package/dist-server/graphql/types/warehouse-inventory-adjustment/index.js +9 -0
- package/dist-server/graphql/types/warehouse-inventory-adjustment/index.js.map +1 -0
- package/dist-server/index.js +2 -5
- package/dist-server/index.js.map +1 -1
- package/dist-server/opa-app-setting-constants.js +2 -1
- package/dist-server/opa-app-setting-constants.js.map +1 -1
- package/dist-server/utils/index.js +1 -5
- package/dist-server/utils/index.js.map +1 -1
- package/helps/release-note.ko.md +10 -8
- package/helps/release-note.md +10 -8
- package/helps/release-note.ms.md +10 -8
- package/helps/release-note.zh.md +10 -8
- package/package.json +66 -66
- package/server/entities/index.ts +2 -2
- package/server/entities/warehouse-bizplace-onhand-inventory.ts +141 -0
- package/server/graphql/resolvers/board-setting/board-settings.ts +4 -2
- package/server/graphql/resolvers/index.ts +3 -2
- package/server/graphql/resolvers/reports/outbound-order-details-report.ts +6 -2
- package/server/graphql/resolvers/warehouse-inventory-adjustment/index.ts +5 -0
- package/server/graphql/resolvers/warehouse-inventory-adjustment/warehouse-intentory-adjustment.ts +68 -0
- package/server/graphql/types/index.ts +4 -4
- package/server/graphql/types/reports/outbound-order-details-report.ts +2 -0
- package/server/graphql/types/warehouse-inventory-adjustment/index.ts +5 -0
- package/server/index.ts +2 -1
- package/server/opa-app-setting-constants.ts +1 -0
- package/things-factory.config.js +13 -0
- package/translations/en.json +48 -8
- package/translations/ko.json +35 -1
- package/translations/ms.json +35 -1
- package/translations/zh.json +35 -1
- package/config.development.js +0 -73
- package/config.production.js +0 -113
|
@@ -0,0 +1,1163 @@
|
|
|
1
|
+
import '@things-factory/grist-ui'
|
|
2
|
+
import '@things-factory/biz-ui'
|
|
3
|
+
import '@things-factory/warehouse-ui'
|
|
4
|
+
|
|
5
|
+
import gql from 'graphql-tag'
|
|
6
|
+
import { css, html } from 'lit-element'
|
|
7
|
+
import { connect } from 'pwa-helpers/connect-mixin'
|
|
8
|
+
|
|
9
|
+
import { getCodeByName } from '@things-factory/code-base'
|
|
10
|
+
import { MultiColumnFormStyles } from '@things-factory/form-ui'
|
|
11
|
+
import { i18next, localize } from '@things-factory/i18n-base'
|
|
12
|
+
import { openPopup } from '@things-factory/layout-base'
|
|
13
|
+
import { fetchSettingRule } from '@things-factory/setting-ui'
|
|
14
|
+
import { client, CustomAlert, navigate, PageView, store } from '@things-factory/shell'
|
|
15
|
+
import { CommonButtonStyles } from '@things-factory/styles'
|
|
16
|
+
import { flattenObject, isMobileDevice } from '@things-factory/utils'
|
|
17
|
+
|
|
18
|
+
import { DRAFT_RELEASE_ORDER_STATUS, PRODUCT_GROUP_TYPES } from '../../../constants'
|
|
19
|
+
|
|
20
|
+
import '@things-factory/import-ui'
|
|
21
|
+
|
|
22
|
+
class DraftReleaseGoodDetail extends connect(store)(localize(i18next)(PageView)) {
|
|
23
|
+
static get properties() {
|
|
24
|
+
return {
|
|
25
|
+
/* Draft RO Form Fields */
|
|
26
|
+
_ownTransport: Boolean,
|
|
27
|
+
_warehouseTransport: Boolean,
|
|
28
|
+
_crossDocking: Boolean,
|
|
29
|
+
_exportOption: Boolean,
|
|
30
|
+
_bizplaces: Object,
|
|
31
|
+
_bizplaceId: String,
|
|
32
|
+
_bizplaceName: String,
|
|
33
|
+
_productData: Object,
|
|
34
|
+
refNo: String,
|
|
35
|
+
refNo2: String,
|
|
36
|
+
refNo3: String,
|
|
37
|
+
releaseDate: Date,
|
|
38
|
+
collectionOrderNo: String,
|
|
39
|
+
/* Draft RO Form Fields */
|
|
40
|
+
|
|
41
|
+
_draftOrderData: Object,
|
|
42
|
+
_enableTransportationServiceSetting: Boolean,
|
|
43
|
+
_enableTransportForCustomClearanceSetting: Boolean,
|
|
44
|
+
_disableTransport: Boolean,
|
|
45
|
+
_editable: Boolean,
|
|
46
|
+
_files: Array,
|
|
47
|
+
_attachments: Array,
|
|
48
|
+
_orderProductGristConfig: Object
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
static get styles() {
|
|
53
|
+
return [
|
|
54
|
+
MultiColumnFormStyles,
|
|
55
|
+
css`
|
|
56
|
+
:host {
|
|
57
|
+
display: flex;
|
|
58
|
+
flex-direction: column;
|
|
59
|
+
overflow-x: auto;
|
|
60
|
+
}
|
|
61
|
+
.container {
|
|
62
|
+
flex: 1;
|
|
63
|
+
display: flex;
|
|
64
|
+
overflow: hidden;
|
|
65
|
+
min-height: 50vh;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
[options-wrap] * {
|
|
69
|
+
vertical-align: middle;
|
|
70
|
+
}
|
|
71
|
+
[options-wrap] input[type='checkbox'] {
|
|
72
|
+
left: 0;
|
|
73
|
+
}
|
|
74
|
+
[options-wrap] input[type='checkbox'] + label {
|
|
75
|
+
margin-right: 20px;
|
|
76
|
+
padding-left: 0;
|
|
77
|
+
}
|
|
78
|
+
[attachment-wrap] {
|
|
79
|
+
display: flex;
|
|
80
|
+
flex-direction: row;
|
|
81
|
+
grid-column: span 24;
|
|
82
|
+
}
|
|
83
|
+
[attachment-wrap] label {
|
|
84
|
+
width: 8%;
|
|
85
|
+
}
|
|
86
|
+
[attachment-wrap] file-uploader {
|
|
87
|
+
flex: 1;
|
|
88
|
+
margin: 0 var(--margin-wide) 0 var(--margin-narrow);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
[attachment-wrap] ul a * {
|
|
92
|
+
vertical-align: middle;
|
|
93
|
+
}
|
|
94
|
+
[attachment-wrap] ul {
|
|
95
|
+
grid-column: span 9 / auto;
|
|
96
|
+
}
|
|
97
|
+
[attachment-wrap] ul a {
|
|
98
|
+
display: block;
|
|
99
|
+
text-overflow: ellipsis;
|
|
100
|
+
overflow: hidden;
|
|
101
|
+
white-space: nowrap;
|
|
102
|
+
color: var(--primary-color);
|
|
103
|
+
font-size: var(--fontsize-default);
|
|
104
|
+
}
|
|
105
|
+
[attachment-wrap] ul {
|
|
106
|
+
margin: 0;
|
|
107
|
+
padding: 0;
|
|
108
|
+
list-style: none;
|
|
109
|
+
}
|
|
110
|
+
[attachment-wrap] ul a mwc-icon {
|
|
111
|
+
font-size: var(--fontsize-default);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
.grist {
|
|
115
|
+
background-color: var(--main-section-background-color);
|
|
116
|
+
display: flex;
|
|
117
|
+
flex-direction: column;
|
|
118
|
+
flex: 1;
|
|
119
|
+
overflow-y: auto;
|
|
120
|
+
}
|
|
121
|
+
data-grist {
|
|
122
|
+
overflow-y: hidden;
|
|
123
|
+
flex: 1;
|
|
124
|
+
}
|
|
125
|
+
h2 {
|
|
126
|
+
padding: var(--subtitle-padding);
|
|
127
|
+
font: var(--subtitle-font);
|
|
128
|
+
color: var(--subtitle-text-color);
|
|
129
|
+
border-bottom: var(--subtitle-border-bottom);
|
|
130
|
+
}
|
|
131
|
+
.grist h2 {
|
|
132
|
+
margin: var(--grist-title-margin);
|
|
133
|
+
border: var(--grist-title-border);
|
|
134
|
+
font: var(--grist-title-font);
|
|
135
|
+
color: var(--secondary-color);
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
.grist h2 mwc-icon {
|
|
139
|
+
vertical-align: middle;
|
|
140
|
+
margin: var(--grist-title-icon-margin);
|
|
141
|
+
font-size: var(--grist-title-icon-size);
|
|
142
|
+
color: var(--grist-title-icon-color);
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
h2 + data-grist {
|
|
146
|
+
padding-top: var(--grist-title-with-grid-padding);
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
[hidden] {
|
|
150
|
+
display: none;
|
|
151
|
+
}
|
|
152
|
+
@media screen and (max-width: 460px) {
|
|
153
|
+
[attachment-wrap] {
|
|
154
|
+
grid-column: span 12;
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
@media screen and (min-width: 1201px) and (max-width: 2000px) {
|
|
158
|
+
[attachment-wrap] {
|
|
159
|
+
grid-column: span 36;
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
@media screen and (min-width: 2001px) {
|
|
163
|
+
[attachment-wrap] {
|
|
164
|
+
grid-column: span 48;
|
|
165
|
+
}
|
|
166
|
+
[attachment-wrap] label {
|
|
167
|
+
width: 6%;
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
`
|
|
171
|
+
]
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
get _draftReleaseOrderForm() {
|
|
175
|
+
return this.shadowRoot.querySelector('form[name=draftReleaseOrder]')
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
get _shippingOrderForm() {
|
|
179
|
+
return this.shadowRoot.querySelector('form[name=shippingOrder]')
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
get _containerArrivalDateInput() {
|
|
183
|
+
return this.shadowRoot.querySelector('input[name=containerArrivalDate]')
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
get _containerLeavingDateInput() {
|
|
187
|
+
return this.shadowRoot.querySelector('input[name=containerLeavingDate]')
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
get _ownTransportInput() {
|
|
191
|
+
return this.shadowRoot.querySelector('input[name=ownTransport]')
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
get _warehouseTransportInput() {
|
|
195
|
+
return this.shadowRoot.querySelector('input[name=warehouseTransport]')
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
get _exportOptionInput() {
|
|
199
|
+
return this.shadowRoot.querySelector('input[name=exportOption]')
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
get _productGrist() {
|
|
203
|
+
return this.shadowRoot.querySelector('data-grist#product-grist')
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
// disable file upload feature. Unable to delete insert / upsert file
|
|
207
|
+
// get _document() {
|
|
208
|
+
// return this.shadowRoot.querySelector('#uploadDocument')
|
|
209
|
+
// }
|
|
210
|
+
|
|
211
|
+
get bizplaceIdInput() {
|
|
212
|
+
return this.shadowRoot.querySelector('input[name=bizplaceId]')
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
get bizplaceNameInput() {
|
|
216
|
+
return this.shadowRoot.querySelector('input[name=bizplaceName]')
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
get _productColumns() {
|
|
220
|
+
return this._productGrist.columns
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
get context() {
|
|
224
|
+
let actions = []
|
|
225
|
+
|
|
226
|
+
if (this._draftOrderData) {
|
|
227
|
+
actions = [
|
|
228
|
+
{
|
|
229
|
+
title: i18next.t('button.to_listing'),
|
|
230
|
+
action: this._navigateToList.bind(this),
|
|
231
|
+
...CommonButtonStyles.back
|
|
232
|
+
}
|
|
233
|
+
]
|
|
234
|
+
|
|
235
|
+
if (
|
|
236
|
+
this._draftOrderData?.status != DRAFT_RELEASE_ORDER_STATUS.PENDING &&
|
|
237
|
+
this._draftOrderData?.status != DRAFT_RELEASE_ORDER_STATUS.SUBMITTED &&
|
|
238
|
+
this._draftOrderData?.status != DRAFT_RELEASE_ORDER_STATUS.CANCELLED
|
|
239
|
+
) {
|
|
240
|
+
actions = [
|
|
241
|
+
{
|
|
242
|
+
title: i18next.t('button.draft'),
|
|
243
|
+
action: this._updateDraftOrder.bind(this, DRAFT_RELEASE_ORDER_STATUS.DRAFT),
|
|
244
|
+
...CommonButtonStyles.draft
|
|
245
|
+
},
|
|
246
|
+
// {
|
|
247
|
+
// title: i18next.t('button.create_ro'),
|
|
248
|
+
// action: this._updateDraftOrder.bind(this, DRAFT_RELEASE_ORDER_STATUS.SUBMITTED),
|
|
249
|
+
// ...CommonButtonStyles.submit
|
|
250
|
+
// },
|
|
251
|
+
...actions
|
|
252
|
+
]
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
return {
|
|
257
|
+
title: `${i18next.t('title.draft_release_order_detail')} `,
|
|
258
|
+
actions,
|
|
259
|
+
help: 'operato-wms/draft-release-order-detail'
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
async pageInitialized() {
|
|
264
|
+
let [enableTransportationServiceSetting, bizplaces, packingTypes] = await Promise.all([
|
|
265
|
+
fetchSettingRule('enable-transportation-service'),
|
|
266
|
+
this.fetchBizplaces(),
|
|
267
|
+
getCodeByName('PACKING_TYPES')
|
|
268
|
+
])
|
|
269
|
+
|
|
270
|
+
this._enableTransportationServiceSetting = enableTransportationServiceSetting
|
|
271
|
+
this._bizplaces = bizplaces
|
|
272
|
+
this.packingTypes = packingTypes
|
|
273
|
+
|
|
274
|
+
this._editable = false
|
|
275
|
+
|
|
276
|
+
this._clearView()
|
|
277
|
+
|
|
278
|
+
if (!this._enableTransportationServiceSetting)
|
|
279
|
+
this._enableTransportationServiceSetting = await fetchSettingRule('enable-transportation-service')
|
|
280
|
+
|
|
281
|
+
if (!this._bizplaces) this._bizplaces = await this.fetchBizplaces()
|
|
282
|
+
|
|
283
|
+
if (!this._packingTypes) this._packingTypes = await getCodeByName('PACKING_TYPES')
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
render() {
|
|
287
|
+
return html`
|
|
288
|
+
<form name="draftReleaseOrder" class="multi-column-form" autocomplete="off">
|
|
289
|
+
<fieldset>
|
|
290
|
+
<legend>${i18next.t('title.draft_release_order')} (${this._orderNo || 'NEW'}) [${
|
|
291
|
+
this._draftOrderData?.status
|
|
292
|
+
}]</legend>
|
|
293
|
+
|
|
294
|
+
<label>${i18next.t('label.options')}</label>
|
|
295
|
+
<div options-wrap>
|
|
296
|
+
<input
|
|
297
|
+
id="ownTransport"
|
|
298
|
+
type="checkbox"
|
|
299
|
+
name="ownTransport"
|
|
300
|
+
?checked="${this._ownTransport}"
|
|
301
|
+
?disabled="${this._disableTransport}"
|
|
302
|
+
@change="${e => {
|
|
303
|
+
this._ownTransport = e.currentTarget.checked
|
|
304
|
+
if (this._ownTransport) {
|
|
305
|
+
this._warehouseTransportInput.checked = false
|
|
306
|
+
this._warehouseTransport = false
|
|
307
|
+
} else {
|
|
308
|
+
this._warehouseTransportInput.checked = true
|
|
309
|
+
this._warehouseTransport = true
|
|
310
|
+
this._exportOptionInput.checked = false
|
|
311
|
+
this._exportOption = false
|
|
312
|
+
}
|
|
313
|
+
this._validateTransport()
|
|
314
|
+
}}"
|
|
315
|
+
/>
|
|
316
|
+
<label for="ownTransport" ?hidden="${this._importedOrder}">${i18next.t('label.own_transport')}</label>
|
|
317
|
+
|
|
318
|
+
<input
|
|
319
|
+
id="warehouseTransport"
|
|
320
|
+
type="checkbox"
|
|
321
|
+
name="warehouseTransport"
|
|
322
|
+
?checked="${this._warehouseTransport}"
|
|
323
|
+
?disabled="${this._disableTransport}"
|
|
324
|
+
@change="${e => {
|
|
325
|
+
this._warehouseTransport = e.currentTarget.checked
|
|
326
|
+
if (this._warehouseTransport) {
|
|
327
|
+
this._ownTransportInput.checked = false
|
|
328
|
+
this._ownTransport = false
|
|
329
|
+
this._exportOptionInput.checked = false
|
|
330
|
+
this._exportOption = false
|
|
331
|
+
} else {
|
|
332
|
+
this._ownTransportInput.checked = true
|
|
333
|
+
this._ownTransport = true
|
|
334
|
+
}
|
|
335
|
+
this._validateTransport()
|
|
336
|
+
}}"
|
|
337
|
+
/>
|
|
338
|
+
<label for="warehouseTransport" ?hidden="${this._importedOrder}"
|
|
339
|
+
>${i18next.t('label.warehouse_transport')}</label
|
|
340
|
+
>
|
|
341
|
+
|
|
342
|
+
<input
|
|
343
|
+
id="exportOption"
|
|
344
|
+
type="checkbox"
|
|
345
|
+
name="exportOption"
|
|
346
|
+
.checked="${this._exportOption}"
|
|
347
|
+
?hidden="${!this._checkTransport}"
|
|
348
|
+
@change="${e => {
|
|
349
|
+
this._exportOption = e.currentTarget.checked
|
|
350
|
+
if (this._exportOption == true) {
|
|
351
|
+
this._warehouseTransportInput.checked = false
|
|
352
|
+
this._warehouseTransport = false
|
|
353
|
+
this._ownTransportInput.checked = true
|
|
354
|
+
this._ownTransport = true
|
|
355
|
+
}
|
|
356
|
+
if (this._warehouseTransport) {
|
|
357
|
+
this._exportOptionInput.checked = false
|
|
358
|
+
this._exportOption = false
|
|
359
|
+
}
|
|
360
|
+
}}"
|
|
361
|
+
/>
|
|
362
|
+
<label for="exportOption" ?hidden="${!this._checkTransport}">${i18next.t('label.export')}</label>
|
|
363
|
+
|
|
364
|
+
<input
|
|
365
|
+
id="packingOption"
|
|
366
|
+
type="checkbox"
|
|
367
|
+
?hidden="${!this._checkTransport}"
|
|
368
|
+
name="packingOption"
|
|
369
|
+
.checked="${this._packingOption}"
|
|
370
|
+
disabled
|
|
371
|
+
/>
|
|
372
|
+
<label for="packingOption" ?hidden="${!this._checkTransport}">${i18next.t('label.packing')}</label>
|
|
373
|
+
</div>
|
|
374
|
+
|
|
375
|
+
<label ?hidden="${!this._checkTransport}">${i18next.t('label.company')}</label>
|
|
376
|
+
<input type="hidden" name="bizplaceId" value="${this._bizplaceId}" />
|
|
377
|
+
<input
|
|
378
|
+
type="text"
|
|
379
|
+
name="bizplaceName"
|
|
380
|
+
value="${this._bizplaceName}"
|
|
381
|
+
@click="${this._openBizplacesSelector.bind(this)}"
|
|
382
|
+
?hidden="${!this._checkTransport}"
|
|
383
|
+
?disabled="${this._orderNo != ''}"
|
|
384
|
+
/>
|
|
385
|
+
|
|
386
|
+
<label ?hidden="${!this._checkTransport}">${i18next.t('label.ref_no')}</label>
|
|
387
|
+
<input name="refNo" .value="${this.refNo}" ?hidden="${!this._checkTransport}" />
|
|
388
|
+
|
|
389
|
+
<label ?hidden="${!this._checkTransport}">${i18next.t('label.ref_no_2')}</label>
|
|
390
|
+
<input name="refNo2" .value="${this.refNo2}" ?hidden="${!this._checkTransport}" />
|
|
391
|
+
|
|
392
|
+
<label ?hidden="${!this._checkTransport}">${i18next.t('label.ref_no_3')}</label>
|
|
393
|
+
<input name="refNo3" .value="${this.refNo3}" ?hidden="${!this._checkTransport}" />
|
|
394
|
+
|
|
395
|
+
<label ?hidden="${!this._checkTransport}">${i18next.t('label.release_date')}</label>
|
|
396
|
+
<input
|
|
397
|
+
name="releaseDate"
|
|
398
|
+
type="date"
|
|
399
|
+
.value="${this.releaseDate}"
|
|
400
|
+
required
|
|
401
|
+
?hidden="${!this._checkTransport}"
|
|
402
|
+
@change="${this._validateDate}"
|
|
403
|
+
/>
|
|
404
|
+
|
|
405
|
+
${
|
|
406
|
+
this._ownTransport
|
|
407
|
+
? html`
|
|
408
|
+
<label>${i18next.t('label.co_no')}</label>
|
|
409
|
+
<input name="collectionOrderNo" .value="${this.collectionOrderNo}" />
|
|
410
|
+
`
|
|
411
|
+
: ''
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
<!-- <div attachment-wrap>
|
|
415
|
+
<label ?hidden="${!this._checkTransport}">${i18next.t('label.upload_documents')}</label>
|
|
416
|
+
<file-uploader
|
|
417
|
+
name="attachments"
|
|
418
|
+
id="uploadDocument"
|
|
419
|
+
label="${i18next.t('label.select_file')}"
|
|
420
|
+
accept="*"
|
|
421
|
+
multiple="true"
|
|
422
|
+
?hidden="${!this._checkTransport}"
|
|
423
|
+
custom-input
|
|
424
|
+
></file-uploader>
|
|
425
|
+
</div> -->
|
|
426
|
+
</fieldset>
|
|
427
|
+
</form>
|
|
428
|
+
|
|
429
|
+
<div class="so-form-container" ?hidden="${!this._exportOption}">
|
|
430
|
+
<form name="shippingOrder" class="multi-column-form" autocomplete="off">
|
|
431
|
+
<fieldset>
|
|
432
|
+
<legend>${i18next.t('title.export_order')}</legend>
|
|
433
|
+
<label>${i18next.t('label.container_no')}</label>
|
|
434
|
+
<input name="containerNo" required .value="${this.containerNo}" />
|
|
435
|
+
|
|
436
|
+
<label>${i18next.t('label.container_arrival_date')}</label>
|
|
437
|
+
<input name="containerArrivalDate" type="date" .value="${this.containerArrivalDate}" required />
|
|
438
|
+
|
|
439
|
+
<label>${i18next.t('label.container_leaving_date')}</label>
|
|
440
|
+
<input name="containerLeavingDate" type="date" .value="${this.containerLeavingDate}" required />
|
|
441
|
+
|
|
442
|
+
<label>${i18next.t('label.ship_name')}</label>
|
|
443
|
+
<input name="shipName" required .value="${this.shipName}" />
|
|
444
|
+
</fieldset>
|
|
445
|
+
</form>
|
|
446
|
+
</div>
|
|
447
|
+
|
|
448
|
+
|
|
449
|
+
<div class="container">
|
|
450
|
+
<div class="grist">
|
|
451
|
+
<h2>
|
|
452
|
+
<mwc-icon>list_alt</mwc-icon>${i18next.t('title.release_product_list')}
|
|
453
|
+
</h2>
|
|
454
|
+
|
|
455
|
+
|
|
456
|
+
<data-grist
|
|
457
|
+
id="product-grist"
|
|
458
|
+
.mode=${isMobileDevice() ? 'LIST' : 'GRID'}
|
|
459
|
+
.data=${this._productData}
|
|
460
|
+
.config=${this._orderProductGristConfig}
|
|
461
|
+
@record-change="${this._onProductChangeHandler.bind(this)}"
|
|
462
|
+
@field-change="${this._onProductFieldChanged.bind(this)}"
|
|
463
|
+
></data-grist>
|
|
464
|
+
|
|
465
|
+
</div>
|
|
466
|
+
</div>
|
|
467
|
+
</div>
|
|
468
|
+
`
|
|
469
|
+
}
|
|
470
|
+
|
|
471
|
+
async pageUpdated(changes, lifecycle) {
|
|
472
|
+
if (this.active) {
|
|
473
|
+
try {
|
|
474
|
+
this._clearView()
|
|
475
|
+
|
|
476
|
+
if (!this._enableTransportationServiceSetting)
|
|
477
|
+
this._enableTransportationServiceSetting = await fetchSettingRule('enable-transportation-service')
|
|
478
|
+
|
|
479
|
+
if (!this._bizplaces) this._bizplaces = await this.fetchBizplaces()
|
|
480
|
+
|
|
481
|
+
if (!this._packingTypes) this._packingTypes = await getCodeByName('PACKING_TYPES')
|
|
482
|
+
|
|
483
|
+
let orderNo = changes.resourceId || this._orderNo
|
|
484
|
+
this._orderNo = orderNo == 'new' ? '' : orderNo
|
|
485
|
+
await this._fetchOrder()
|
|
486
|
+
|
|
487
|
+
this.updateContext()
|
|
488
|
+
} catch (e) {
|
|
489
|
+
this._showToast(e)
|
|
490
|
+
} finally {
|
|
491
|
+
this.updateContext()
|
|
492
|
+
}
|
|
493
|
+
}
|
|
494
|
+
}
|
|
495
|
+
|
|
496
|
+
_initProperties() {
|
|
497
|
+
this._exportOption = false
|
|
498
|
+
this.refNo = ''
|
|
499
|
+
this.refNo2 = ''
|
|
500
|
+
this.refNo3 = ''
|
|
501
|
+
this.releaseDate = ''
|
|
502
|
+
this.collectionOrderNo = ''
|
|
503
|
+
this._bizplaceName = null
|
|
504
|
+
this._bizplaceId = null
|
|
505
|
+
this._files = []
|
|
506
|
+
this.containerNo = ''
|
|
507
|
+
this.containerArrivalDate = ''
|
|
508
|
+
this.containerLeavingDate = ''
|
|
509
|
+
this.shipName = ''
|
|
510
|
+
this._productData = { ...this._productData, records: [] }
|
|
511
|
+
this._initialiseProductGristConfig()
|
|
512
|
+
}
|
|
513
|
+
|
|
514
|
+
async fetchBizplaces() {
|
|
515
|
+
const filters = []
|
|
516
|
+
const response = await client.query({
|
|
517
|
+
query: gql`
|
|
518
|
+
query partnersBizplaces($filters: [Filter!]) {
|
|
519
|
+
partnersBizplaces(filters: $filters) {
|
|
520
|
+
items {
|
|
521
|
+
id
|
|
522
|
+
name
|
|
523
|
+
description
|
|
524
|
+
}
|
|
525
|
+
}
|
|
526
|
+
}
|
|
527
|
+
`,
|
|
528
|
+
variables: { filters }
|
|
529
|
+
})
|
|
530
|
+
|
|
531
|
+
if (!response.errors) {
|
|
532
|
+
const bizplaces = response.data.partnersBizplaces.items
|
|
533
|
+
|
|
534
|
+
return bizplaces
|
|
535
|
+
}
|
|
536
|
+
}
|
|
537
|
+
|
|
538
|
+
_onProductFieldChanged(e) {
|
|
539
|
+
this._productData = {
|
|
540
|
+
...this._productData,
|
|
541
|
+
...this._productGrist.dirtyData,
|
|
542
|
+
records: this._productGrist.dirtyData.records.map((record, idx) => {
|
|
543
|
+
let returnObj = {
|
|
544
|
+
...record,
|
|
545
|
+
...record.product,
|
|
546
|
+
product: { ...record.product, id: record.product.id || record.product.productId },
|
|
547
|
+
name: record.name ? record.name : idx,
|
|
548
|
+
releaseQty: record.releaseQty < 0 ? 0 : record.releaseQty,
|
|
549
|
+
id: record.id
|
|
550
|
+
}
|
|
551
|
+
return returnObj
|
|
552
|
+
})
|
|
553
|
+
}
|
|
554
|
+
this._updateProductGristConfig()
|
|
555
|
+
}
|
|
556
|
+
|
|
557
|
+
_initialiseProductGristConfig() {
|
|
558
|
+
this._editable = this._draftOrderData?.status == DRAFT_RELEASE_ORDER_STATUS.DRAFT
|
|
559
|
+
this._orderProductGristConfig = {
|
|
560
|
+
pagination: { infinite: true },
|
|
561
|
+
rows: {
|
|
562
|
+
selectable: { multiple: false }
|
|
563
|
+
},
|
|
564
|
+
list: { fields: ['inventory', 'product', 'location', 'releaseQty'] },
|
|
565
|
+
columns: [
|
|
566
|
+
{ type: 'gutter', gutterName: 'sequence' },
|
|
567
|
+
{
|
|
568
|
+
type: 'gutter',
|
|
569
|
+
gutterName: 'button',
|
|
570
|
+
icon: 'close',
|
|
571
|
+
handlers: {
|
|
572
|
+
click: (columns, data, column, record, rowIndex) => {
|
|
573
|
+
try {
|
|
574
|
+
const newData = data.records.filter((_, idx) => idx !== rowIndex)
|
|
575
|
+
this._productData = { ...this._productData, records: newData }
|
|
576
|
+
this._productGrist.dirtyData.records = newData
|
|
577
|
+
this._updateProductGristConfig()
|
|
578
|
+
} catch (e) {
|
|
579
|
+
this._showToast(e)
|
|
580
|
+
}
|
|
581
|
+
}
|
|
582
|
+
}
|
|
583
|
+
},
|
|
584
|
+
{
|
|
585
|
+
type: 'object',
|
|
586
|
+
name: 'product',
|
|
587
|
+
header: i18next.t('field.product'),
|
|
588
|
+
record: {
|
|
589
|
+
editable: !!this._bizplaceId && this._editable,
|
|
590
|
+
options: {
|
|
591
|
+
queryName: 'allBizplaceProductInventory',
|
|
592
|
+
basicArgs: {
|
|
593
|
+
filters: [{ name: 'bizplace_id', operator: 'eq', value: this._bizplaceId }]
|
|
594
|
+
},
|
|
595
|
+
nameField: 'productSKU',
|
|
596
|
+
descriptionField: 'productName',
|
|
597
|
+
select: [
|
|
598
|
+
{ name: 'id', hidden: true },
|
|
599
|
+
{ name: 'productId', hidden: true },
|
|
600
|
+
{ name: 'remainUomValue', hidden: true },
|
|
601
|
+
{
|
|
602
|
+
name: 'groupType',
|
|
603
|
+
header: i18next.t('field.group_type'),
|
|
604
|
+
ignoreCondition: true
|
|
605
|
+
},
|
|
606
|
+
{
|
|
607
|
+
name: 'productSKU',
|
|
608
|
+
header: i18next.t('field.sku'),
|
|
609
|
+
width: 150
|
|
610
|
+
},
|
|
611
|
+
{
|
|
612
|
+
name: 'productName',
|
|
613
|
+
header: i18next.t('field.product_info'),
|
|
614
|
+
width: 280
|
|
615
|
+
},
|
|
616
|
+
{ name: 'productBrand', header: i18next.t('field.brand') },
|
|
617
|
+
{ name: 'packingType', header: i18next.t('field.packing_type') },
|
|
618
|
+
{ name: 'packingSize', header: i18next.t('field.packing_size') },
|
|
619
|
+
{ name: 'uom', header: i18next.t('field.uom') },
|
|
620
|
+
{
|
|
621
|
+
name: 'remainQty',
|
|
622
|
+
header: i18next.t('field.remain_qty'),
|
|
623
|
+
ignoreCondition: true
|
|
624
|
+
},
|
|
625
|
+
{
|
|
626
|
+
name: 'remainUomValueWithUom',
|
|
627
|
+
header: i18next.t('field.remain_uom_value'),
|
|
628
|
+
ignoreCondition: true
|
|
629
|
+
}
|
|
630
|
+
],
|
|
631
|
+
list: {
|
|
632
|
+
fields: ['groupType', 'productName', 'productBrand', 'packingType', 'remainQty', 'remainUomValue']
|
|
633
|
+
}
|
|
634
|
+
}
|
|
635
|
+
},
|
|
636
|
+
width: 300
|
|
637
|
+
},
|
|
638
|
+
{
|
|
639
|
+
type: 'string',
|
|
640
|
+
name: 'groupType',
|
|
641
|
+
header: i18next.t('field.group_type'),
|
|
642
|
+
width: 100
|
|
643
|
+
},
|
|
644
|
+
{
|
|
645
|
+
type: 'string',
|
|
646
|
+
name: 'productBrand',
|
|
647
|
+
header: i18next.t('field.brand'),
|
|
648
|
+
width: 100
|
|
649
|
+
},
|
|
650
|
+
{
|
|
651
|
+
type: 'code',
|
|
652
|
+
name: 'packingType',
|
|
653
|
+
header: i18next.t('field.packing_type'),
|
|
654
|
+
record: {
|
|
655
|
+
codeName: 'PACKING_TYPES'
|
|
656
|
+
},
|
|
657
|
+
width: 150
|
|
658
|
+
},
|
|
659
|
+
{
|
|
660
|
+
type: 'number',
|
|
661
|
+
name: 'packingSize',
|
|
662
|
+
header: i18next.t('field.packing_size'),
|
|
663
|
+
width: 140
|
|
664
|
+
},
|
|
665
|
+
{
|
|
666
|
+
type: 'string',
|
|
667
|
+
name: 'uom',
|
|
668
|
+
header: i18next.t('field.uom'),
|
|
669
|
+
width: 100
|
|
670
|
+
},
|
|
671
|
+
{
|
|
672
|
+
type: 'integer',
|
|
673
|
+
name: 'remainQty',
|
|
674
|
+
header: i18next.t('field.available_qty'),
|
|
675
|
+
width: 140
|
|
676
|
+
},
|
|
677
|
+
{
|
|
678
|
+
type: 'string',
|
|
679
|
+
name: 'remainUomValueWithUom',
|
|
680
|
+
header: i18next.t('field.available_uom_value'),
|
|
681
|
+
width: 140
|
|
682
|
+
},
|
|
683
|
+
{
|
|
684
|
+
type: 'integer',
|
|
685
|
+
name: 'releaseQty',
|
|
686
|
+
header: i18next.t('field.release_qty'),
|
|
687
|
+
imex: { header: i18next.t('field.release_qty'), key: 'releaseQty', width: 25, type: 'float' },
|
|
688
|
+
record: { editable: this._editable },
|
|
689
|
+
width: 140
|
|
690
|
+
},
|
|
691
|
+
{
|
|
692
|
+
type: 'string',
|
|
693
|
+
name: 'remark',
|
|
694
|
+
header: i18next.t('field.remark'),
|
|
695
|
+
record: { editable: this._editable },
|
|
696
|
+
width: 200
|
|
697
|
+
}
|
|
698
|
+
]
|
|
699
|
+
}
|
|
700
|
+
}
|
|
701
|
+
|
|
702
|
+
_updateProductGristConfig() {
|
|
703
|
+
const _selectedInv = (this._productData.records || []).map(record => {
|
|
704
|
+
return {
|
|
705
|
+
productId: record?.product?.id || record?.product?.productId,
|
|
706
|
+
packingType: record?.packingType,
|
|
707
|
+
packingSize: record?.packingSize,
|
|
708
|
+
uom: record?.uom,
|
|
709
|
+
groupType: record?.groupType
|
|
710
|
+
}
|
|
711
|
+
})
|
|
712
|
+
|
|
713
|
+
this._orderProductGristConfig = {
|
|
714
|
+
...this._orderProductGristConfig,
|
|
715
|
+
columns: this._orderProductGristConfig.columns.map(column => {
|
|
716
|
+
if (column.name === 'product') {
|
|
717
|
+
column.record.options.basicArgs = {
|
|
718
|
+
...column.record.options.basicArgs,
|
|
719
|
+
filters: [
|
|
720
|
+
...column.record.options.basicArgs.filters.filter(
|
|
721
|
+
filter => filter.name !== 'product' && filter.name !== 'batch_bundle'
|
|
722
|
+
)
|
|
723
|
+
]
|
|
724
|
+
}
|
|
725
|
+
if (_selectedInv.length) {
|
|
726
|
+
const _selectedSingleInv = _selectedInv.filter(inv => inv.groupType === PRODUCT_GROUP_TYPES.SINGLE)
|
|
727
|
+
const _selectedBundleInv = _selectedInv.filter(inv => inv.groupType === PRODUCT_GROUP_TYPES.BUNDLE)
|
|
728
|
+
if (_selectedSingleInv.length)
|
|
729
|
+
column.record.options.basicArgs.filters.push({
|
|
730
|
+
name: 'product',
|
|
731
|
+
value: _selectedSingleInv,
|
|
732
|
+
operator: 'notin'
|
|
733
|
+
})
|
|
734
|
+
if (_selectedBundleInv.length)
|
|
735
|
+
column.record.options.basicArgs.filters.push({
|
|
736
|
+
name: 'batch_bundle',
|
|
737
|
+
value: _selectedBundleInv,
|
|
738
|
+
operator: 'notin'
|
|
739
|
+
})
|
|
740
|
+
}
|
|
741
|
+
}
|
|
742
|
+
return column
|
|
743
|
+
})
|
|
744
|
+
}
|
|
745
|
+
}
|
|
746
|
+
|
|
747
|
+
_onProductChangeHandler(event) {
|
|
748
|
+
const changeRecord = event.detail.after
|
|
749
|
+
const changedColumn = event.detail.column.name
|
|
750
|
+
try {
|
|
751
|
+
this._updateProductGristConfig()
|
|
752
|
+
} catch (e) {
|
|
753
|
+
const beforeValue = event.detail.before && event.detail.before[event.detail.column.name]
|
|
754
|
+
if (beforeValue) {
|
|
755
|
+
event.detail.after[event.detail.column.name] = beforeValue
|
|
756
|
+
} else {
|
|
757
|
+
delete event.detail.after[event.detail.column.name]
|
|
758
|
+
}
|
|
759
|
+
this._showToast(e)
|
|
760
|
+
}
|
|
761
|
+
}
|
|
762
|
+
|
|
763
|
+
async _fetchOrder() {
|
|
764
|
+
if (!this._orderNo) {
|
|
765
|
+
this._draftOrderData = {
|
|
766
|
+
bizplace:
|
|
767
|
+
this._bizplaces?.length > 1
|
|
768
|
+
? { id: null, name: '' }
|
|
769
|
+
: { id: this._bizplaces[0].id, name: this._bizplaces[0].name },
|
|
770
|
+
status: DRAFT_RELEASE_ORDER_STATUS.DRAFT
|
|
771
|
+
}
|
|
772
|
+
return
|
|
773
|
+
} else {
|
|
774
|
+
const response = await client.query({
|
|
775
|
+
query: gql`
|
|
776
|
+
query draftReleaseGoodByName($name: String!) {
|
|
777
|
+
draftReleaseGoodByName(name: $name) {
|
|
778
|
+
id
|
|
779
|
+
name
|
|
780
|
+
truckNo
|
|
781
|
+
type
|
|
782
|
+
attentionTo
|
|
783
|
+
phone1
|
|
784
|
+
deliveryAddress1
|
|
785
|
+
bizplace {
|
|
786
|
+
id
|
|
787
|
+
name
|
|
788
|
+
}
|
|
789
|
+
status
|
|
790
|
+
refNo
|
|
791
|
+
refNo2
|
|
792
|
+
refNo3
|
|
793
|
+
ownTransport
|
|
794
|
+
packingOption
|
|
795
|
+
releaseDate
|
|
796
|
+
collectionOrderNo
|
|
797
|
+
attachment {
|
|
798
|
+
id
|
|
799
|
+
name
|
|
800
|
+
refBy
|
|
801
|
+
path
|
|
802
|
+
mimetype
|
|
803
|
+
}
|
|
804
|
+
bizplace {
|
|
805
|
+
id
|
|
806
|
+
name
|
|
807
|
+
description
|
|
808
|
+
}
|
|
809
|
+
orderProducts {
|
|
810
|
+
id
|
|
811
|
+
name
|
|
812
|
+
product {
|
|
813
|
+
id
|
|
814
|
+
name
|
|
815
|
+
brand
|
|
816
|
+
sku
|
|
817
|
+
description
|
|
818
|
+
}
|
|
819
|
+
packingType
|
|
820
|
+
packingSize
|
|
821
|
+
uomValue
|
|
822
|
+
uom
|
|
823
|
+
releaseQty
|
|
824
|
+
totalUomValue
|
|
825
|
+
remark
|
|
826
|
+
remainQty
|
|
827
|
+
remainUomValue
|
|
828
|
+
remainUomValueWithUom
|
|
829
|
+
groupType
|
|
830
|
+
}
|
|
831
|
+
shippingOrder {
|
|
832
|
+
id
|
|
833
|
+
containerNo
|
|
834
|
+
containerLeavingDate
|
|
835
|
+
containerArrivalDate
|
|
836
|
+
shipName
|
|
837
|
+
}
|
|
838
|
+
createdAt
|
|
839
|
+
updatedAt
|
|
840
|
+
updater {
|
|
841
|
+
id
|
|
842
|
+
name
|
|
843
|
+
description
|
|
844
|
+
}
|
|
845
|
+
creator {
|
|
846
|
+
id
|
|
847
|
+
name
|
|
848
|
+
description
|
|
849
|
+
}
|
|
850
|
+
}
|
|
851
|
+
}
|
|
852
|
+
`,
|
|
853
|
+
variables: { name: this._orderNo }
|
|
854
|
+
})
|
|
855
|
+
|
|
856
|
+
if (!response.errors) {
|
|
857
|
+
this._draftOrderData = {
|
|
858
|
+
...response.data.draftReleaseGoodByName
|
|
859
|
+
// shippingOrder: this._exportOption ? this._serializeForm(this._shippingOrderForm) : null
|
|
860
|
+
}
|
|
861
|
+
|
|
862
|
+
this._productData = {
|
|
863
|
+
records: response.data.draftReleaseGoodByName.orderProducts.map(itm => {
|
|
864
|
+
return {
|
|
865
|
+
...itm,
|
|
866
|
+
product: { ...itm.product, productSKU: itm.product.sku, productName: itm.product.name },
|
|
867
|
+
brand: itm.product.brand,
|
|
868
|
+
id: itm.id
|
|
869
|
+
}
|
|
870
|
+
})
|
|
871
|
+
}
|
|
872
|
+
|
|
873
|
+
if (response.data?.draftReleaseGoodByName?.shippingOrder) {
|
|
874
|
+
this._exportOption = true
|
|
875
|
+
this._fillUpForm(response.data.draftReleaseGoodByName.shippingOrder, this._shippingOrderForm)
|
|
876
|
+
}
|
|
877
|
+
|
|
878
|
+
if (this._draftOrderData && this._draftOrderData?.attachment) {
|
|
879
|
+
this._attachments = this._draftOrderData.attachment
|
|
880
|
+
|
|
881
|
+
// disable file upload feature. Unable to delete insert / upsert file
|
|
882
|
+
// if (this._document) {
|
|
883
|
+
// this._document._files = data.attachment
|
|
884
|
+
// }
|
|
885
|
+
}
|
|
886
|
+
|
|
887
|
+
this._ownTransport = this._draftOrderData.ownTransport
|
|
888
|
+
this._bizplaceId = this._draftOrderData.bizplace.id
|
|
889
|
+
this._bizplaceName = this._draftOrderData.bizplace.name
|
|
890
|
+
|
|
891
|
+
this._draftOrderData.warehouseTransport = !!!this._draftOrderData.ownTransport || false
|
|
892
|
+
this._warehouseTransport = this._draftOrderData.warehouseTransport
|
|
893
|
+
|
|
894
|
+
this._fillUpForm(
|
|
895
|
+
flattenObject({ ...this._draftOrderData, bizplaceId: this._bizplaceId, bizplaceName: this._bizplaceName })
|
|
896
|
+
)
|
|
897
|
+
}
|
|
898
|
+
}
|
|
899
|
+
this._initialiseProductGristConfig()
|
|
900
|
+
this._validateTransport()
|
|
901
|
+
this._updateProductGristConfig()
|
|
902
|
+
}
|
|
903
|
+
|
|
904
|
+
async _updateDraftOrder(status) {
|
|
905
|
+
try {
|
|
906
|
+
this._validateForm()
|
|
907
|
+
this._validateProducts()
|
|
908
|
+
|
|
909
|
+
const result = await CustomAlert({
|
|
910
|
+
title: i18next.t('title.are_you_sure'),
|
|
911
|
+
text: i18next.t('text.update_draft_release_order'),
|
|
912
|
+
confirmButton: { text: i18next.t('button.submit') },
|
|
913
|
+
cancelButton: { text: i18next.t('button.cancel') }
|
|
914
|
+
})
|
|
915
|
+
|
|
916
|
+
if (!result.value) return
|
|
917
|
+
|
|
918
|
+
let draftOrder = {
|
|
919
|
+
...this._draftOrderData,
|
|
920
|
+
...this._getFormInfo(),
|
|
921
|
+
bizplace: { id: this._bizplaceId, name: this._bizplaceName }
|
|
922
|
+
}
|
|
923
|
+
|
|
924
|
+
// const fileUploader = this._document?.files ? this._document.files : undefined
|
|
925
|
+
const fileUploader = undefined
|
|
926
|
+
|
|
927
|
+
const objectNames = [
|
|
928
|
+
'bizplace|name',
|
|
929
|
+
'bizplaceId',
|
|
930
|
+
'bizplaceName',
|
|
931
|
+
'warehouseTransport',
|
|
932
|
+
'orderProducts',
|
|
933
|
+
'shippingOrderInfo',
|
|
934
|
+
'shippingOrder',
|
|
935
|
+
'attachment',
|
|
936
|
+
'creator',
|
|
937
|
+
'updater',
|
|
938
|
+
'createdAt',
|
|
939
|
+
'updatedAt'
|
|
940
|
+
]
|
|
941
|
+
|
|
942
|
+
objectNames.forEach(objectName => {
|
|
943
|
+
delete draftOrder[objectName]
|
|
944
|
+
})
|
|
945
|
+
|
|
946
|
+
let variables = {
|
|
947
|
+
draftReleaseGood: {
|
|
948
|
+
...draftOrder,
|
|
949
|
+
status,
|
|
950
|
+
ownTransport: this._ownTransport
|
|
951
|
+
},
|
|
952
|
+
orderProducts: this._getOrderProducts(),
|
|
953
|
+
files: fileUploader,
|
|
954
|
+
shippingOrder: this._exportOption ? this._serializeForm(this._shippingOrderForm) : null
|
|
955
|
+
}
|
|
956
|
+
|
|
957
|
+
const response = await client.mutate({
|
|
958
|
+
mutation: gql`
|
|
959
|
+
mutation upsertDraftReleaseGood(
|
|
960
|
+
$draftReleaseGood: DraftReleaseGoodPatch!
|
|
961
|
+
$orderProducts: [OrderProductPatch!]!
|
|
962
|
+
$files: [Upload!]
|
|
963
|
+
$shippingOrder: ShippingOrderPatch
|
|
964
|
+
) {
|
|
965
|
+
upsertDraftReleaseGood(
|
|
966
|
+
draftReleaseGood: $draftReleaseGood
|
|
967
|
+
orderProducts: $orderProducts
|
|
968
|
+
files: $files
|
|
969
|
+
shippingOrder: $shippingOrder
|
|
970
|
+
) {
|
|
971
|
+
id
|
|
972
|
+
name
|
|
973
|
+
}
|
|
974
|
+
}
|
|
975
|
+
`,
|
|
976
|
+
variables,
|
|
977
|
+
context: { hasUpload: true }
|
|
978
|
+
})
|
|
979
|
+
|
|
980
|
+
if (!response.errors) {
|
|
981
|
+
this._showToast({ message: i18next.t('text.draft_order_saved') })
|
|
982
|
+
this._clearView()
|
|
983
|
+
this._navigateToList()
|
|
984
|
+
}
|
|
985
|
+
} catch (e) {
|
|
986
|
+
this._showToast(e)
|
|
987
|
+
}
|
|
988
|
+
}
|
|
989
|
+
|
|
990
|
+
_validateTransport() {
|
|
991
|
+
//Check if warehouse provide transport
|
|
992
|
+
if (this._enableTransportationServiceSetting != undefined && !this._enableTransportationServiceSetting) {
|
|
993
|
+
this._disableTransport = true
|
|
994
|
+
this._ownTransportInput.checked = true
|
|
995
|
+
this._ownTransport = true
|
|
996
|
+
}
|
|
997
|
+
|
|
998
|
+
if (this._ownTransport || this._warehouseTransport) {
|
|
999
|
+
this._checkTransport = true
|
|
1000
|
+
}
|
|
1001
|
+
}
|
|
1002
|
+
|
|
1003
|
+
_validateForm() {
|
|
1004
|
+
if (!this._draftReleaseOrderForm.checkValidity()) throw new Error(i18next.t('text.draft_order_form_invalid'))
|
|
1005
|
+
|
|
1006
|
+
if (this._draftOrderData?.container && !this.containerNo.value)
|
|
1007
|
+
throw new Error(i18next.t('text.container_no_is_empty'))
|
|
1008
|
+
}
|
|
1009
|
+
|
|
1010
|
+
_validateProducts() {
|
|
1011
|
+
// no records
|
|
1012
|
+
// const records = this._productGrist.dirtyData.records
|
|
1013
|
+
// if (!records?.length) throw new Error(i18next.t('text.no_products'))
|
|
1014
|
+
|
|
1015
|
+
// const checkRequiredFields = ({ releaseQty, product }) => !releaseQty || !product
|
|
1016
|
+
// if (records.some(checkRequiredFields)) {
|
|
1017
|
+
// throw new Error(i18next.t('text.empty_value_in_list'))
|
|
1018
|
+
// }
|
|
1019
|
+
if (!this._productGrist.dirtyData.records || !this._productGrist.dirtyData.records.length)
|
|
1020
|
+
throw new Error(i18next.t('text.there_is_no_product'))
|
|
1021
|
+
|
|
1022
|
+
if (this._productGrist.dirtyData.records.some(record => !record.product || !record.product.id))
|
|
1023
|
+
throw new Error(i18next.t('text.invalid_product'))
|
|
1024
|
+
|
|
1025
|
+
if (this._productGrist.dirtyData.records.some(record => !record.packingType))
|
|
1026
|
+
throw new Error(i18next.t('text.invalid_packing_type'))
|
|
1027
|
+
|
|
1028
|
+
if (this._productGrist.dirtyData.records.some(record => !record.releaseQty))
|
|
1029
|
+
throw new Error(i18next.t('text.invalid_release_qty'))
|
|
1030
|
+
|
|
1031
|
+
return true
|
|
1032
|
+
}
|
|
1033
|
+
|
|
1034
|
+
_getFormInfo() {
|
|
1035
|
+
const formData = this._serializeForm(this._draftReleaseOrderForm)
|
|
1036
|
+
return formData
|
|
1037
|
+
}
|
|
1038
|
+
|
|
1039
|
+
_getOrderProducts() {
|
|
1040
|
+
return this._productGrist.dirtyData.records.map(record => {
|
|
1041
|
+
let orderProduct = {
|
|
1042
|
+
id: record.id ? record.id.toString() : null,
|
|
1043
|
+
name: record.name ? record.name.toString() : null,
|
|
1044
|
+
product: { id: record.product.id },
|
|
1045
|
+
packingType: record.packingType,
|
|
1046
|
+
uomValue: record?.uomValue ? record.uomValue : 0,
|
|
1047
|
+
uom: record.uom,
|
|
1048
|
+
releaseQty: record.releaseQty,
|
|
1049
|
+
totalUomValue: record?.uomValue ? `${(record.uomValue * record.packQty).toFixed(2)} ${record.uom}` : ``,
|
|
1050
|
+
remark: record?.remark || null
|
|
1051
|
+
}
|
|
1052
|
+
|
|
1053
|
+
return orderProduct
|
|
1054
|
+
})
|
|
1055
|
+
}
|
|
1056
|
+
|
|
1057
|
+
_getStdDate() {
|
|
1058
|
+
let date = new Date()
|
|
1059
|
+
date.setDate(date.getDate())
|
|
1060
|
+
return date.toISOString().split('T')[0]
|
|
1061
|
+
}
|
|
1062
|
+
|
|
1063
|
+
_validateDate(e) {
|
|
1064
|
+
let inputDate = e.currentTarget.value
|
|
1065
|
+
let todayDate = this._getStdDate()
|
|
1066
|
+
if (inputDate < todayDate) {
|
|
1067
|
+
this._showToast({
|
|
1068
|
+
message: 'Invalid date'
|
|
1069
|
+
})
|
|
1070
|
+
}
|
|
1071
|
+
return inputDate
|
|
1072
|
+
}
|
|
1073
|
+
|
|
1074
|
+
_clearView() {
|
|
1075
|
+
this.refNo = ''
|
|
1076
|
+
this.refNo2 = ''
|
|
1077
|
+
this.refNo3 = ''
|
|
1078
|
+
this.releaseDate = ''
|
|
1079
|
+
this.collectionOrderNo = ''
|
|
1080
|
+
this._bizplaceName = null
|
|
1081
|
+
this._bizplaceId = null
|
|
1082
|
+
this._files = []
|
|
1083
|
+
this.containerNo = ''
|
|
1084
|
+
this.containerArrivalDate = ''
|
|
1085
|
+
this.containerLeavingDate = ''
|
|
1086
|
+
this.shipName = ''
|
|
1087
|
+
|
|
1088
|
+
this._checkTransport = null
|
|
1089
|
+
this._ownTransport = false
|
|
1090
|
+
this._warehouseTransport = false
|
|
1091
|
+
this._exportOption = false
|
|
1092
|
+
|
|
1093
|
+
this._draftOrderData = null
|
|
1094
|
+
this._draftReleaseOrderForm.reset()
|
|
1095
|
+
this._attachments = []
|
|
1096
|
+
this._productData = { records: [] }
|
|
1097
|
+
|
|
1098
|
+
this._initialiseProductGristConfig()
|
|
1099
|
+
this._validateTransport()
|
|
1100
|
+
}
|
|
1101
|
+
|
|
1102
|
+
_serializeForm(form) {
|
|
1103
|
+
let obj = {}
|
|
1104
|
+
Array.from(form.querySelectorAll('input, select')).forEach(field => {
|
|
1105
|
+
if (!field.hasAttribute('hidden') && field.value) {
|
|
1106
|
+
obj[field.name] = field.type === 'checkbox' ? field.checked : field.value
|
|
1107
|
+
}
|
|
1108
|
+
})
|
|
1109
|
+
|
|
1110
|
+
return obj
|
|
1111
|
+
}
|
|
1112
|
+
|
|
1113
|
+
_openBizplacesSelector() {
|
|
1114
|
+
if (this._orderNo == '') {
|
|
1115
|
+
openPopup(
|
|
1116
|
+
html`
|
|
1117
|
+
<popup-partner-bizplaces-selector
|
|
1118
|
+
@selected="${e => {
|
|
1119
|
+
this._bizplaceId = e.detail.id
|
|
1120
|
+
this._bizplaceName = e.detail.name
|
|
1121
|
+
this._initialiseProductGristConfig()
|
|
1122
|
+
}}"
|
|
1123
|
+
></popup-partner-bizplaces-selector>
|
|
1124
|
+
`,
|
|
1125
|
+
{
|
|
1126
|
+
backdrop: true,
|
|
1127
|
+
size: 'large',
|
|
1128
|
+
title: i18next.t('title.select_company')
|
|
1129
|
+
}
|
|
1130
|
+
)
|
|
1131
|
+
}
|
|
1132
|
+
}
|
|
1133
|
+
|
|
1134
|
+
_navigateToList() {
|
|
1135
|
+
navigate(`draft_release_goods`)
|
|
1136
|
+
}
|
|
1137
|
+
|
|
1138
|
+
_fillUpForm(data, form = this._draftReleaseOrderForm) {
|
|
1139
|
+
data = flattenObject(data)
|
|
1140
|
+
// for (let key in data) {
|
|
1141
|
+
Array.from(form.querySelectorAll('input, textarea, select')).forEach(field => {
|
|
1142
|
+
if (field.type === 'checkbox') {
|
|
1143
|
+
field.checked = data[field.name] || false
|
|
1144
|
+
} else {
|
|
1145
|
+
field.value = data[field.name] || ''
|
|
1146
|
+
}
|
|
1147
|
+
})
|
|
1148
|
+
// }
|
|
1149
|
+
}
|
|
1150
|
+
|
|
1151
|
+
_showToast({ type, message }) {
|
|
1152
|
+
document.dispatchEvent(
|
|
1153
|
+
new CustomEvent('notify', {
|
|
1154
|
+
detail: {
|
|
1155
|
+
type,
|
|
1156
|
+
message
|
|
1157
|
+
}
|
|
1158
|
+
})
|
|
1159
|
+
)
|
|
1160
|
+
}
|
|
1161
|
+
}
|
|
1162
|
+
|
|
1163
|
+
window.customElements.define('draft-release-good-detail', DraftReleaseGoodDetail)
|