@things-factory/meta-ui 7.0.1-alpha.56 → 7.0.1-alpha.58
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/mixin/meta-form-mixin.js +350 -347
- package/client/utils/value-util.js +74 -72
- package/dist-client/mixin/meta-form-mixin.d.ts +9 -5
- package/dist-client/mixin/meta-form-mixin.js +14 -12
- package/dist-client/mixin/meta-form-mixin.js.map +1 -1
- package/dist-client/tsconfig.tsbuildinfo +1 -1
- package/dist-client/utils/value-util.js +6 -4
- package/dist-client/utils/value-util.js.map +1 -1
- package/dist-server/tsconfig.tsbuildinfo +1 -1
- package/package.json +7 -7
|
@@ -14,419 +14,422 @@ import { MetaButtonMixin } from './meta-button-mixin'
|
|
|
14
14
|
* @author Shortstop shortstop@hatiolab.com
|
|
15
15
|
* @description 메뉴 메타 정보를 이용해 폼 화면 구성
|
|
16
16
|
*/
|
|
17
|
-
export const MetaFormMixin =
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
17
|
+
export const MetaFormMixin = baseElement =>
|
|
18
|
+
class extends MetaButtonMixin(baseElement) {
|
|
19
|
+
/**
|
|
20
|
+
* @description 스타일 정의
|
|
21
|
+
**************************
|
|
22
|
+
* @returns {Array} 스타일
|
|
23
|
+
*/
|
|
24
|
+
static get styles() {
|
|
25
|
+
return MetaApi.getBasicFormStyles()
|
|
26
|
+
}
|
|
26
27
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
28
|
+
/**
|
|
29
|
+
* @description 프로퍼티 정의
|
|
30
|
+
***************************
|
|
31
|
+
* @returns {Object} 프로퍼티
|
|
32
|
+
*/
|
|
33
|
+
static get properties() {
|
|
34
|
+
return {
|
|
35
|
+
/**
|
|
36
|
+
* @description 폽 컬럼 구성 정보
|
|
37
|
+
******************************
|
|
38
|
+
* @type {Array}
|
|
39
|
+
*/
|
|
40
|
+
formColumnConfig: Array,
|
|
41
|
+
/**
|
|
42
|
+
* @description 메뉴 메타 정보로 부터 추출한 후 폼을 위해 설정 정보 구성
|
|
43
|
+
************************************************************
|
|
44
|
+
* @type {Object}
|
|
45
|
+
*/
|
|
46
|
+
formConfigSet: Object,
|
|
47
|
+
/**
|
|
48
|
+
* @description 폼 상세 렌터링 정보
|
|
49
|
+
*******************************
|
|
50
|
+
* @type {Object}
|
|
51
|
+
*/
|
|
52
|
+
formRenderConfig: Array,
|
|
53
|
+
/**
|
|
54
|
+
* @description 데이터 레코드
|
|
55
|
+
***************************
|
|
56
|
+
* @type {Object}
|
|
57
|
+
*/
|
|
58
|
+
record: Object
|
|
59
|
+
}
|
|
58
60
|
}
|
|
59
|
-
}
|
|
60
61
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
62
|
+
/**
|
|
63
|
+
* @description 컨텍스트
|
|
64
|
+
***********************
|
|
65
|
+
* @returns {HTMLElement}
|
|
66
|
+
*/
|
|
67
|
+
get context() {
|
|
68
|
+
return MetaUiUtil.getContextObject(this)
|
|
69
|
+
}
|
|
69
70
|
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
71
|
+
/******************************************************
|
|
72
|
+
* LifeCycle
|
|
73
|
+
******************************************************/
|
|
73
74
|
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
75
|
+
/**
|
|
76
|
+
* @override connectedCallback
|
|
77
|
+
*******************************
|
|
78
|
+
*/
|
|
79
|
+
async connectedCallback() {
|
|
80
|
+
// 메뉴 메타 정보 조회 및 기본 파싱
|
|
81
|
+
await this.getAndParseMenuMeta()
|
|
81
82
|
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
83
|
+
if (this.isElement) {
|
|
84
|
+
await this.parseFormConfigs()
|
|
85
|
+
}
|
|
85
86
|
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
87
|
+
if (this.activityDataSet) {
|
|
88
|
+
this.dataSet = this.activityDataSet
|
|
89
|
+
}
|
|
89
90
|
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
91
|
+
if (this.is_activity === true && !this.parent_id) {
|
|
92
|
+
this.parent_id = 'activity'
|
|
93
|
+
}
|
|
93
94
|
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
95
|
+
if (super.connectedCallback) {
|
|
96
|
+
await super.connectedCallback()
|
|
97
|
+
}
|
|
97
98
|
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
99
|
+
if (this.isElement) {
|
|
100
|
+
await this.fetch()
|
|
101
|
+
}
|
|
101
102
|
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
103
|
+
// 인풋 키 이벤트 처리
|
|
104
|
+
this.renderRoot.addEventListener('keydown', e => {
|
|
105
|
+
switch (e.key) {
|
|
106
|
+
case 'Esc':
|
|
107
|
+
case 'Escape':
|
|
108
|
+
// TODO 편집이 취소되어야 한다.
|
|
109
|
+
case 'Enter':
|
|
110
|
+
// 먼저 focus를 옮겨놓아야 focusout으로 인해서 popup이 닫히는 것을 방지할 수 있다.
|
|
111
|
+
this.focus()
|
|
112
|
+
|
|
113
|
+
if (this.currentTarget) {
|
|
114
|
+
this.currentTarget.removeAttribute('editing')
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
this.currentTarget = null
|
|
118
|
+
break
|
|
119
|
+
default:
|
|
120
|
+
}
|
|
121
|
+
})
|
|
111
122
|
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
123
|
+
// 인풋 클릭 처리 (readOnly <> editing)
|
|
124
|
+
this.renderRoot.addEventListener('click', e => {
|
|
125
|
+
e.stopPropagation()
|
|
126
|
+
// target should be 'ox-grid-field'
|
|
127
|
+
let target = e.target
|
|
115
128
|
|
|
129
|
+
if (this.currentTarget) {
|
|
130
|
+
this.focus()
|
|
131
|
+
this.currentTarget.removeAttribute('editing')
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
if (target.tagName !== 'OX-GRID-FIELD' || !target.column.record.editable) {
|
|
135
|
+
this.focus()
|
|
116
136
|
this.currentTarget = null
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
}
|
|
120
|
-
})
|
|
137
|
+
return
|
|
138
|
+
}
|
|
121
139
|
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
// target should be 'ox-grid-field'
|
|
126
|
-
let target = e.target;
|
|
140
|
+
this.currentTarget = target
|
|
141
|
+
target.setAttribute('editing', 'true')
|
|
142
|
+
})
|
|
127
143
|
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
}
|
|
144
|
+
// 폼 뷰의 인풋에서 발생되는 변경 이벤트 처리
|
|
145
|
+
this.addEventListener('field-change', e => {
|
|
146
|
+
let { after, before, column, record, row } = e.detail
|
|
132
147
|
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
}
|
|
148
|
+
// before, after 값으로 달라진 값이 없으면 스킵
|
|
149
|
+
if (ValueUtil.isEquals(after, before)) {
|
|
150
|
+
return
|
|
151
|
+
}
|
|
138
152
|
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
153
|
+
// 유효성 체크 함수가 있는 경우 해당 함수 호출
|
|
154
|
+
let validation = column.validation
|
|
155
|
+
if (validation && typeof validation == 'function') {
|
|
156
|
+
if (!validation.call(this, after, before, record, column)) {
|
|
157
|
+
return
|
|
158
|
+
}
|
|
159
|
+
}
|
|
142
160
|
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
161
|
+
// 변경 값 셋팅
|
|
162
|
+
let colName = column.name
|
|
163
|
+
record[colName] = after
|
|
146
164
|
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
165
|
+
// 변경 필드 정보
|
|
166
|
+
record.__dirtyfields__ = record.__dirtyfields__ || {}
|
|
167
|
+
record.__origin__ = record.__origin__ || {}
|
|
168
|
+
record.__dirtyfields__[colName] = {
|
|
169
|
+
before: record.__origin__[colName],
|
|
170
|
+
after: record[colName]
|
|
171
|
+
}
|
|
151
172
|
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
if (!validation.call(this, after, before, record, column)) {
|
|
156
|
-
return
|
|
173
|
+
// 같은 값으로 변경 되었다면
|
|
174
|
+
if (ValueUtil.isEquals(record.__dirtyfields__[colName].before, record.__dirtyfields__[colName].after)) {
|
|
175
|
+
delete record.__dirtyfields__[colName]
|
|
157
176
|
}
|
|
158
|
-
}
|
|
159
177
|
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
record[colName] = after
|
|
178
|
+
// dirty flag 설정
|
|
179
|
+
record.__dirty__ = ValueUtil.isNotEmpty(record.__dirtyfields__) ? 'M' : ''
|
|
163
180
|
|
|
164
|
-
|
|
165
|
-
record.__dirtyfields__ = record.__dirtyfields__ || {}
|
|
166
|
-
record.__origin__ = record.__origin__ || {}
|
|
167
|
-
record.__dirtyfields__[colName] = {
|
|
168
|
-
before: record.__origin__[colName],
|
|
169
|
-
after: record[colName]
|
|
170
|
-
}
|
|
181
|
+
this.record = { ...record }
|
|
171
182
|
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
183
|
+
// form-field-change 변경 이벤트 전파
|
|
184
|
+
this.dispatchEvent(
|
|
185
|
+
new CustomEvent('form-field-change', {
|
|
186
|
+
bubbles: true,
|
|
187
|
+
composed: true,
|
|
188
|
+
detail: e.detail
|
|
189
|
+
})
|
|
190
|
+
)
|
|
191
|
+
})
|
|
192
|
+
}
|
|
176
193
|
|
|
177
|
-
|
|
178
|
-
|
|
194
|
+
/**
|
|
195
|
+
* @override firstUpdated
|
|
196
|
+
***************************
|
|
197
|
+
*/
|
|
198
|
+
async firstUpdated() {
|
|
199
|
+
if (super.firstUpdated) {
|
|
200
|
+
await super.firstUpdated()
|
|
201
|
+
}
|
|
202
|
+
}
|
|
179
203
|
|
|
180
|
-
|
|
204
|
+
/**
|
|
205
|
+
* @override pageInitialized
|
|
206
|
+
*****************************
|
|
207
|
+
*/
|
|
208
|
+
async pageInitialized() {
|
|
209
|
+
if (this.isPage) {
|
|
210
|
+
await this.parseFormConfigs()
|
|
211
|
+
}
|
|
181
212
|
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
bubbles: true,
|
|
186
|
-
composed: true,
|
|
187
|
-
detail: e.detail
|
|
188
|
-
})
|
|
189
|
-
)
|
|
190
|
-
})
|
|
191
|
-
}
|
|
213
|
+
if (super.pageInitialized) {
|
|
214
|
+
await super.pageInitialized()
|
|
215
|
+
}
|
|
192
216
|
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
*/
|
|
197
|
-
async firstUpdated() {
|
|
198
|
-
if (super.firstUpdated) {
|
|
199
|
-
await super.firstUpdated()
|
|
217
|
+
if (this.isPage) {
|
|
218
|
+
await this.fetch()
|
|
219
|
+
}
|
|
200
220
|
}
|
|
201
|
-
}
|
|
202
221
|
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
222
|
+
/**
|
|
223
|
+
* @description 화면 그리기
|
|
224
|
+
*************************
|
|
225
|
+
* @returns {HTMLElement}
|
|
226
|
+
*/
|
|
227
|
+
render() {
|
|
228
|
+
return MetaApi.getBasicFormHtml(this)
|
|
210
229
|
}
|
|
211
230
|
|
|
212
|
-
|
|
213
|
-
|
|
231
|
+
/**
|
|
232
|
+
* @descrtiption 메뉴 메타 정보로 부터 기본 폼 정보 구성을 위한 Configuration
|
|
233
|
+
*******************************************************************
|
|
234
|
+
* @param {Object} menuMeta 메뉴 메타 정보
|
|
235
|
+
*/
|
|
236
|
+
parseBasicFormConfigs(menuMeta) {
|
|
237
|
+
this.formColumnConfig = menuMeta.grid_column
|
|
238
|
+
this.formRenderConfig = menuMeta.form
|
|
214
239
|
}
|
|
215
240
|
|
|
216
|
-
|
|
217
|
-
|
|
241
|
+
/**
|
|
242
|
+
* @descrtiption 폼 구성 정보 Configuration
|
|
243
|
+
*****************************************
|
|
244
|
+
*/
|
|
245
|
+
async parseFormConfigs() {
|
|
246
|
+
this.formConfigSet = await MetaApi.parseFormConfigSet(this)
|
|
218
247
|
}
|
|
219
|
-
}
|
|
220
248
|
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
249
|
+
/********************************************************************
|
|
250
|
+
* Data Filtering
|
|
251
|
+
********************************************************************/
|
|
252
|
+
|
|
253
|
+
/**
|
|
254
|
+
* @description 최초 조회된 원본 데이터
|
|
255
|
+
***********************************
|
|
256
|
+
* @returns {Object} 원본 데이터 (변경 값 무시)
|
|
257
|
+
*/
|
|
258
|
+
get orgData() {
|
|
259
|
+
return this.removeGarbageData(this.record.__origin__)
|
|
260
|
+
}
|
|
229
261
|
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
262
|
+
/**
|
|
263
|
+
* @description 변경된 데이터
|
|
264
|
+
**************************
|
|
265
|
+
* @returns {Object} 변경된 데이터만
|
|
266
|
+
*/
|
|
267
|
+
get dirtyData() {
|
|
268
|
+
if (ValueUtil.isEmpty((this.record || {}).__dirtyfields__)) {
|
|
269
|
+
return {}
|
|
270
|
+
}
|
|
239
271
|
|
|
240
|
-
|
|
241
|
-
* @descrtiption 폼 구성 정보 Configuration
|
|
242
|
-
*****************************************
|
|
243
|
-
*/
|
|
244
|
-
async parseFormConfigs() {
|
|
245
|
-
this.formConfigSet = await MetaApi.parseFormConfigSet(this)
|
|
246
|
-
}
|
|
272
|
+
let retData = {}
|
|
247
273
|
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
* @description 최초 조회된 원본 데이터
|
|
254
|
-
***********************************
|
|
255
|
-
* @returns {Object} 원본 데이터 (변경 값 무시)
|
|
256
|
-
*/
|
|
257
|
-
get orgData() {
|
|
258
|
-
return this.removeGarbageData(this.record.__origin__)
|
|
259
|
-
}
|
|
274
|
+
Object.entries(this.record.__dirtyfields__).map(([key, value]) => {
|
|
275
|
+
if (key.startsWith('__') == false) {
|
|
276
|
+
retData[key] = value.after
|
|
277
|
+
}
|
|
278
|
+
})
|
|
260
279
|
|
|
261
|
-
|
|
262
|
-
* @description 변경된 데이터
|
|
263
|
-
**************************
|
|
264
|
-
* @returns {Object} 변경된 데이터만
|
|
265
|
-
*/
|
|
266
|
-
get dirtyData() {
|
|
267
|
-
if (ValueUtil.isEmpty((this.record || {}).__dirtyfields__)) {
|
|
268
|
-
return {}
|
|
280
|
+
return retData
|
|
269
281
|
}
|
|
270
282
|
|
|
271
|
-
|
|
283
|
+
/**
|
|
284
|
+
* @description 현재 데이터
|
|
285
|
+
*************************
|
|
286
|
+
* @returns {Object} 화면에 표현되어 있는 현재 데이터 (수정된 값 반영)
|
|
287
|
+
*/
|
|
288
|
+
get currentData() {
|
|
289
|
+
return this.removeGarbageData(this.record)
|
|
290
|
+
}
|
|
272
291
|
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
292
|
+
/**
|
|
293
|
+
* @description 레코드 데이터에서 쓰레기 데이터 정리
|
|
294
|
+
********************************************
|
|
295
|
+
* @returns {Object} __dirty__,__dirtyfields__,__origin__ 등 (__ 로 시작되는 데이터 삭제)
|
|
296
|
+
*/
|
|
297
|
+
removeGarbageData(data) {
|
|
298
|
+
if (!data) return undefined
|
|
278
299
|
|
|
279
|
-
|
|
280
|
-
}
|
|
300
|
+
let retData = {}
|
|
281
301
|
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
get currentData() {
|
|
288
|
-
return this.removeGarbageData(this.record)
|
|
289
|
-
}
|
|
302
|
+
Object.entries(data).map(([key, value]) => {
|
|
303
|
+
if (key.startsWith('__') == false) {
|
|
304
|
+
retData[key] = value
|
|
305
|
+
}
|
|
306
|
+
})
|
|
290
307
|
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
********************************************
|
|
294
|
-
* @returns {Object} __dirty__,__dirtyfields__,__origin__ 등 (__ 로 시작되는 데이터 삭제)
|
|
295
|
-
*/
|
|
296
|
-
removeGarbageData(data) {
|
|
297
|
-
if(!data) return undefined
|
|
308
|
+
return retData
|
|
309
|
+
}
|
|
298
310
|
|
|
299
|
-
|
|
311
|
+
/**
|
|
312
|
+
* @description 트랜잭션을 위한 변경 데이터 + cuFlag 가져오기
|
|
313
|
+
*****************************************************
|
|
314
|
+
* @returns {Object}
|
|
315
|
+
*/
|
|
316
|
+
get patchData() {
|
|
317
|
+
let dirtyData = this.dirtyData
|
|
318
|
+
let recordData = this.record
|
|
319
|
+
// 코드 인풋 타입
|
|
320
|
+
let codeInputColumns = (this.formColumnConfig || []).filter(x => x.type === 'code-input').map(x => x.name)
|
|
321
|
+
|
|
322
|
+
if (ValueUtil.isEmpty(dirtyData)) {
|
|
323
|
+
return undefined
|
|
324
|
+
}
|
|
300
325
|
|
|
301
|
-
|
|
302
|
-
if (
|
|
303
|
-
|
|
326
|
+
// 기존 데이터 존재 여부 - 변경 플래그 판단
|
|
327
|
+
if (ValueUtil.isNotEmpty(recordData.id)) {
|
|
328
|
+
dirtyData.id = recordData.id
|
|
329
|
+
dirtyData.cuFlag = 'M'
|
|
330
|
+
} else {
|
|
331
|
+
dirtyData.cuFlag = '+'
|
|
304
332
|
}
|
|
305
|
-
})
|
|
306
333
|
|
|
307
|
-
|
|
308
|
-
|
|
334
|
+
// object 타입은 id만 전송되도록 변경
|
|
335
|
+
Object.keys(dirtyData).forEach(key => {
|
|
336
|
+
if (typeof dirtyData[key] === 'object' && codeInputColumns.includes(key) == false) {
|
|
337
|
+
dirtyData[key] = { id: dirtyData[key].id }
|
|
338
|
+
}
|
|
339
|
+
})
|
|
309
340
|
|
|
310
|
-
|
|
311
|
-
* @description 트랜잭션을 위한 변경 데이터 + cuFlag 가져오기
|
|
312
|
-
*****************************************************
|
|
313
|
-
* @returns {Object}
|
|
314
|
-
*/
|
|
315
|
-
get patchData() {
|
|
316
|
-
let dirtyData = this.dirtyData
|
|
317
|
-
let recordData = this.record
|
|
318
|
-
// 코드 인풋 타입
|
|
319
|
-
let codeInputColumns = (this.formColumnConfig || []).filter(x => x.type === 'code-input').map(x => x.name)
|
|
320
|
-
|
|
321
|
-
if (ValueUtil.isEmpty(dirtyData)) {
|
|
322
|
-
return undefined
|
|
341
|
+
return [dirtyData]
|
|
323
342
|
}
|
|
324
343
|
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
344
|
+
/********************************************************************
|
|
345
|
+
* C R U D Functions
|
|
346
|
+
********************************************************************/
|
|
347
|
+
/**
|
|
348
|
+
* @description 폼 데이터 조회
|
|
349
|
+
***************************
|
|
350
|
+
*/
|
|
351
|
+
async fetch() {
|
|
352
|
+
// 부모 ID가 없다면 리턴
|
|
353
|
+
if (ValueUtil.isEmpty(this.parent_id)) return
|
|
354
|
+
|
|
355
|
+
// 단건 조회 함수
|
|
356
|
+
let findOneFunc = ValueUtil.getParams(this.gqlInfo, 'query', 'find_one_func')
|
|
357
|
+
if (!findOneFunc) return
|
|
358
|
+
|
|
359
|
+
// 부모 ID로 조회
|
|
360
|
+
let data = await this.findOne(this.parent_id)
|
|
361
|
+
|
|
362
|
+
// 데이터 형식 맞추기
|
|
363
|
+
data['__seq__'] = 1
|
|
364
|
+
let orgData = {}
|
|
365
|
+
Object.assign(orgData, data)
|
|
366
|
+
data['__origin__'] = orgData
|
|
367
|
+
this.record = { ...data }
|
|
331
368
|
}
|
|
332
369
|
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
370
|
+
/**
|
|
371
|
+
* @description 폼 데이터 저장
|
|
372
|
+
*****************************
|
|
373
|
+
* @returns {Boolean} 저장 여부
|
|
374
|
+
*/
|
|
375
|
+
async save() {
|
|
376
|
+
let patches = this.patchData
|
|
377
|
+
|
|
378
|
+
// 변경 여부 메시지 처리
|
|
379
|
+
if (ValueUtil.isEmpty(patches)) {
|
|
380
|
+
MetaApi.showAlertPopup('title.info', 'text.NOTHING_CHANGED', 'warning', 'confirm')
|
|
381
|
+
return
|
|
337
382
|
}
|
|
338
|
-
})
|
|
339
383
|
|
|
340
|
-
|
|
341
|
-
|
|
384
|
+
// 필수 입력 컬럼
|
|
385
|
+
let mandatoryColumns = {}
|
|
386
|
+
;(this.formColumnConfig || [])
|
|
387
|
+
.filter(x => x.mandatory === true)
|
|
388
|
+
.forEach(x => {
|
|
389
|
+
mandatoryColumns[x.name] = x.header
|
|
390
|
+
})
|
|
342
391
|
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
// 부모 ID가 없다면 리턴
|
|
352
|
-
if (ValueUtil.isEmpty(this.parent_id)) return
|
|
353
|
-
|
|
354
|
-
// 단건 조회 함수
|
|
355
|
-
let findOneFunc = ValueUtil.getParams(this.gqlInfo, 'query', 'find_one_func')
|
|
356
|
-
if(!findOneFunc) return;
|
|
357
|
-
|
|
358
|
-
// 부모 ID로 조회
|
|
359
|
-
let data = await this.findOne(this.parent_id)
|
|
360
|
-
|
|
361
|
-
// 데이터 형식 맞추기
|
|
362
|
-
data['__seq__'] = 1
|
|
363
|
-
let orgData = {};
|
|
364
|
-
Object.assign(orgData, data)
|
|
365
|
-
data['__origin__'] = orgData
|
|
366
|
-
this.record = { ...data }
|
|
367
|
-
}
|
|
392
|
+
// 필수 입력 값 체크
|
|
393
|
+
let allFields = this.currentData
|
|
394
|
+
for (let key in mandatoryColumns) {
|
|
395
|
+
if (allFields[key] === undefined || allFields[key] == '') {
|
|
396
|
+
UiUtil.showAlertPopup('text.check-mandatory', TermsUtil.tText('check-mandatory-field', { x: TermsUtil.tLabel(mandatoryColumns[key]) }), 'info', 'confirm')
|
|
397
|
+
return
|
|
398
|
+
}
|
|
399
|
+
}
|
|
368
400
|
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
async save() {
|
|
375
|
-
let patches = this.patchData
|
|
376
|
-
|
|
377
|
-
// 변경 여부 메시지 처리
|
|
378
|
-
if (ValueUtil.isEmpty(patches)) {
|
|
379
|
-
MetaApi.showAlertPopup('title.info', 'text.NOTHING_CHANGED')
|
|
380
|
-
return
|
|
381
|
-
}
|
|
401
|
+
// 저장 서비스 호출
|
|
402
|
+
let isRes = await this.updateMultiple(patches)
|
|
403
|
+
if (isRes) {
|
|
404
|
+
// 폼 데이터 조회
|
|
405
|
+
await this.fetch()
|
|
382
406
|
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
})
|
|
388
|
-
|
|
389
|
-
// 필수 입력 값 체크
|
|
390
|
-
let allFields = this.currentData
|
|
391
|
-
for(let key in mandatoryColumns) {
|
|
392
|
-
if(allFields[key] === undefined || allFields[key] == '') {
|
|
393
|
-
UiUtil.showAlertPopup('text.check-mandatory', TermsUtil.tText('check-mandatory-field', { x: TermsUtil.tLabel(mandatoryColumns[key]) }), 'info', 'confirm')
|
|
394
|
-
return
|
|
407
|
+
// 저장이 잘 되었고 팝업이라면 팝업 닫기
|
|
408
|
+
if (this.isPopup) {
|
|
409
|
+
closePopup(this)
|
|
410
|
+
}
|
|
395
411
|
}
|
|
396
|
-
}
|
|
397
412
|
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
// 폼 데이터 조회
|
|
402
|
-
await this.fetch()
|
|
413
|
+
// 저장 결과 리턴
|
|
414
|
+
return isRes
|
|
415
|
+
}
|
|
403
416
|
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
417
|
+
/**
|
|
418
|
+
* @description 데이터 클리어
|
|
419
|
+
***************************
|
|
420
|
+
*/
|
|
421
|
+
async clear() {
|
|
422
|
+
if (this.record) {
|
|
423
|
+
this.record = {}
|
|
407
424
|
}
|
|
408
425
|
}
|
|
409
426
|
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
*/
|
|
418
|
-
async clear() {
|
|
419
|
-
if(this.record) {
|
|
420
|
-
this.record = {};
|
|
427
|
+
/**
|
|
428
|
+
* @description 데이터 리턴
|
|
429
|
+
*************************
|
|
430
|
+
* @returns {Object}
|
|
431
|
+
*/
|
|
432
|
+
getData() {
|
|
433
|
+
return this.currentData || {}
|
|
421
434
|
}
|
|
422
435
|
}
|
|
423
|
-
|
|
424
|
-
/**
|
|
425
|
-
* @description 데이터 리턴
|
|
426
|
-
*************************
|
|
427
|
-
* @returns {Object}
|
|
428
|
-
*/
|
|
429
|
-
getData() {
|
|
430
|
-
return this.currentData || {}
|
|
431
|
-
}
|
|
432
|
-
}
|