@things-factory/kpi 9.0.22 → 9.0.24

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (189) hide show
  1. package/client/pages/kpi/kpi-list-page.ts +180 -22
  2. package/client/pages/kpi/kpi-viz-editor.ts +1 -1
  3. package/client/pages/kpi-category/kpi-category-list-page.ts +76 -3
  4. package/client/pages/kpi-category/kpi-category-value-calculator.ts +233 -0
  5. package/client/pages/kpi-category-value/kpi-category-value-list-page.ts +404 -0
  6. package/client/pages/kpi-metric/kpi-metric-list-page.ts +13 -1
  7. package/client/pages/kpi-metric-value/kpi-metric-value-editor-page.ts +763 -0
  8. package/client/pages/kpi-metric-value/kpi-metric-value-list-page.ts +55 -1
  9. package/client/pages/kpi-metric-value/kpi-metric-value-manual-entry-form.ts +3 -13
  10. package/client/pages/kpi-metric-value/kpi-metric-value-manual-entry-page.ts +13 -1
  11. package/client/pages/kpi-value/kpi-value-editor-page.ts +774 -0
  12. package/client/pages/kpi-value/kpi-value-list-page.ts +58 -1
  13. package/client/route.ts +16 -0
  14. package/dist-client/pages/kpi/kpi-list-page.d.ts +2 -1
  15. package/dist-client/pages/kpi/kpi-list-page.js +180 -22
  16. package/dist-client/pages/kpi/kpi-list-page.js.map +1 -1
  17. package/dist-client/pages/kpi/kpi-viz-editor.d.ts +0 -1
  18. package/dist-client/pages/kpi/kpi-viz-editor.js +1 -1
  19. package/dist-client/pages/kpi/kpi-viz-editor.js.map +1 -1
  20. package/dist-client/pages/kpi-category/kpi-category-list-page.d.ts +3 -0
  21. package/dist-client/pages/kpi-category/kpi-category-list-page.js +71 -3
  22. package/dist-client/pages/kpi-category/kpi-category-list-page.js.map +1 -1
  23. package/dist-client/pages/kpi-category/kpi-category-value-calculator.d.ts +13 -0
  24. package/dist-client/pages/kpi-category/kpi-category-value-calculator.js +256 -0
  25. package/dist-client/pages/kpi-category/kpi-category-value-calculator.js.map +1 -0
  26. package/dist-client/pages/kpi-category-value/kpi-category-value-list-page.d.ts +63 -0
  27. package/dist-client/pages/kpi-category-value/kpi-category-value-list-page.js +393 -0
  28. package/dist-client/pages/kpi-category-value/kpi-category-value-list-page.js.map +1 -0
  29. package/dist-client/pages/kpi-metric/kpi-metric-list-page.js +13 -1
  30. package/dist-client/pages/kpi-metric/kpi-metric-list-page.js.map +1 -1
  31. package/dist-client/pages/kpi-metric-value/kpi-metric-value-editor-page.d.ts +58 -0
  32. package/dist-client/pages/kpi-metric-value/kpi-metric-value-editor-page.js +736 -0
  33. package/dist-client/pages/kpi-metric-value/kpi-metric-value-editor-page.js.map +1 -0
  34. package/dist-client/pages/kpi-metric-value/kpi-metric-value-list-page.d.ts +5 -1
  35. package/dist-client/pages/kpi-metric-value/kpi-metric-value-list-page.js +50 -2
  36. package/dist-client/pages/kpi-metric-value/kpi-metric-value-list-page.js.map +1 -1
  37. package/dist-client/pages/kpi-metric-value/kpi-metric-value-manual-entry-form.js +3 -13
  38. package/dist-client/pages/kpi-metric-value/kpi-metric-value-manual-entry-form.js.map +1 -1
  39. package/dist-client/pages/kpi-metric-value/kpi-metric-value-manual-entry-page.js +13 -1
  40. package/dist-client/pages/kpi-metric-value/kpi-metric-value-manual-entry-page.js.map +1 -1
  41. package/dist-client/pages/kpi-value/kpi-value-editor-page.d.ts +55 -0
  42. package/dist-client/pages/kpi-value/kpi-value-editor-page.js +748 -0
  43. package/dist-client/pages/kpi-value/kpi-value-editor-page.js.map +1 -0
  44. package/dist-client/pages/kpi-value/kpi-value-list-page.d.ts +10 -2
  45. package/dist-client/pages/kpi-value/kpi-value-list-page.js +57 -1
  46. package/dist-client/pages/kpi-value/kpi-value-list-page.js.map +1 -1
  47. package/dist-client/route.d.ts +1 -1
  48. package/dist-client/route.js +12 -0
  49. package/dist-client/route.js.map +1 -1
  50. package/dist-client/tsconfig.tsbuildinfo +1 -1
  51. package/dist-server/calculator/evaluator.d.ts +8 -0
  52. package/dist-server/calculator/evaluator.js +42 -0
  53. package/dist-server/calculator/evaluator.js.map +1 -0
  54. package/dist-server/calculator/functions.d.ts +3 -0
  55. package/dist-server/calculator/functions.js +62 -0
  56. package/dist-server/calculator/functions.js.map +1 -0
  57. package/dist-server/calculator/index.d.ts +4 -0
  58. package/dist-server/calculator/index.js +8 -0
  59. package/dist-server/calculator/index.js.map +1 -0
  60. package/dist-server/calculator/parser.d.ts +21 -0
  61. package/dist-server/calculator/parser.js +121 -0
  62. package/dist-server/calculator/parser.js.map +1 -0
  63. package/dist-server/calculator/provider.d.ts +8 -0
  64. package/dist-server/calculator/provider.js +13 -0
  65. package/dist-server/calculator/provider.js.map +1 -0
  66. package/dist-server/controllers/kpi-metric-value-provider.d.ts +11 -0
  67. package/dist-server/controllers/kpi-metric-value-provider.js +63 -0
  68. package/dist-server/controllers/kpi-metric-value-provider.js.map +1 -0
  69. package/dist-server/controllers/kpi-value-provider.d.ts +11 -0
  70. package/dist-server/controllers/kpi-value-provider.js +46 -0
  71. package/dist-server/controllers/kpi-value-provider.js.map +1 -0
  72. package/dist-server/service/index.d.ts +4 -2
  73. package/dist-server/service/index.js +5 -0
  74. package/dist-server/service/index.js.map +1 -1
  75. package/dist-server/service/kpi/aggregate-kpi.js +4 -4
  76. package/dist-server/service/kpi/aggregate-kpi.js.map +1 -1
  77. package/dist-server/service/kpi/kpi-grade.types.d.ts +11 -10
  78. package/dist-server/service/kpi/kpi-grade.types.js.map +1 -1
  79. package/dist-server/service/kpi/kpi-history.d.ts +2 -2
  80. package/dist-server/service/kpi/kpi-history.js.map +1 -1
  81. package/dist-server/service/kpi/kpi-mutation.d.ts +2 -0
  82. package/dist-server/service/kpi/kpi-mutation.js +126 -4
  83. package/dist-server/service/kpi/kpi-mutation.js.map +1 -1
  84. package/dist-server/service/kpi/kpi-type.d.ts +8 -5
  85. package/dist-server/service/kpi/kpi-type.js +22 -8
  86. package/dist-server/service/kpi/kpi-type.js.map +1 -1
  87. package/dist-server/service/kpi/kpi.d.ts +6 -3
  88. package/dist-server/service/kpi/kpi.js +29 -9
  89. package/dist-server/service/kpi/kpi.js.map +1 -1
  90. package/dist-server/service/kpi-category/kpi-category-mutation.d.ts +3 -4
  91. package/dist-server/service/kpi-category/kpi-category-mutation.js +151 -80
  92. package/dist-server/service/kpi-category/kpi-category-mutation.js.map +1 -1
  93. package/dist-server/service/kpi-category/kpi-category-query.d.ts +5 -0
  94. package/dist-server/service/kpi-category/kpi-category-query.js +19 -1
  95. package/dist-server/service/kpi-category/kpi-category-query.js.map +1 -1
  96. package/dist-server/service/kpi-category/kpi-category-type.d.ts +3 -0
  97. package/dist-server/service/kpi-category/kpi-category-type.js +16 -1
  98. package/dist-server/service/kpi-category/kpi-category-type.js.map +1 -1
  99. package/dist-server/service/kpi-category/kpi-category.d.ts +2 -0
  100. package/dist-server/service/kpi-category/kpi-category.js +10 -1
  101. package/dist-server/service/kpi-category/kpi-category.js.map +1 -1
  102. package/dist-server/service/kpi-category-value/index.d.ts +6 -0
  103. package/dist-server/service/kpi-category-value/index.js +10 -0
  104. package/dist-server/service/kpi-category-value/index.js.map +1 -0
  105. package/dist-server/service/kpi-category-value/kpi-category-value-mutation.d.ts +8 -0
  106. package/dist-server/service/kpi-category-value/kpi-category-value-mutation.js +102 -0
  107. package/dist-server/service/kpi-category-value/kpi-category-value-mutation.js.map +1 -0
  108. package/dist-server/service/kpi-category-value/kpi-category-value-query.d.ts +13 -0
  109. package/dist-server/service/kpi-category-value/kpi-category-value-query.js +91 -0
  110. package/dist-server/service/kpi-category-value/kpi-category-value-query.js.map +1 -0
  111. package/dist-server/service/kpi-category-value/kpi-category-value-type.d.ts +19 -0
  112. package/dist-server/service/kpi-category-value/kpi-category-value-type.js +73 -0
  113. package/dist-server/service/kpi-category-value/kpi-category-value-type.js.map +1 -0
  114. package/dist-server/service/kpi-category-value/kpi-category-value.d.ts +19 -0
  115. package/dist-server/service/kpi-category-value/kpi-category-value.js +91 -0
  116. package/dist-server/service/kpi-category-value/kpi-category-value.js.map +1 -0
  117. package/dist-server/service/kpi-metric/kpi-metric-type.d.ts +5 -3
  118. package/dist-server/service/kpi-metric/kpi-metric-type.js +5 -3
  119. package/dist-server/service/kpi-metric/kpi-metric-type.js.map +1 -1
  120. package/dist-server/service/kpi-metric/kpi-metric.d.ts +2 -8
  121. package/dist-server/service/kpi-metric/kpi-metric.js +3 -14
  122. package/dist-server/service/kpi-metric/kpi-metric.js.map +1 -1
  123. package/dist-server/service/kpi-metric-value/kpi-metric-value-mutation.js +87 -45
  124. package/dist-server/service/kpi-metric-value/kpi-metric-value-mutation.js.map +1 -1
  125. package/dist-server/service/kpi-metric-value/kpi-metric-value.js +3 -2
  126. package/dist-server/service/kpi-metric-value/kpi-metric-value.js.map +1 -1
  127. package/dist-server/service/kpi-value/kpi-value-mutation.d.ts +3 -1
  128. package/dist-server/service/kpi-value/kpi-value-mutation.js +174 -6
  129. package/dist-server/service/kpi-value/kpi-value-mutation.js.map +1 -1
  130. package/dist-server/service/kpi-value/kpi-value-query.d.ts +0 -2
  131. package/dist-server/service/kpi-value/kpi-value-query.js +0 -12
  132. package/dist-server/service/kpi-value/kpi-value-query.js.map +1 -1
  133. package/dist-server/service/kpi-value/kpi-value-score.service.d.ts +26 -0
  134. package/dist-server/service/kpi-value/kpi-value-score.service.js +97 -0
  135. package/dist-server/service/kpi-value/kpi-value-score.service.js.map +1 -0
  136. package/dist-server/service/kpi-value/kpi-value-type.d.ts +2 -0
  137. package/dist-server/service/kpi-value/kpi-value-type.js +14 -0
  138. package/dist-server/service/kpi-value/kpi-value-type.js.map +1 -1
  139. package/dist-server/service/kpi-value/kpi-value.d.ts +1 -0
  140. package/dist-server/service/kpi-value/kpi-value.js +9 -1
  141. package/dist-server/service/kpi-value/kpi-value.js.map +1 -1
  142. package/dist-server/service/utils/value-date-util.d.ts +3 -0
  143. package/dist-server/service/utils/value-date-util.js +76 -0
  144. package/dist-server/service/utils/value-date-util.js.map +1 -0
  145. package/dist-server/tsconfig.tsbuildinfo +1 -1
  146. package/package.json +5 -5
  147. package/server/calculator/evaluator.ts +45 -0
  148. package/server/calculator/functions.ts +67 -0
  149. package/server/calculator/index.ts +4 -0
  150. package/server/calculator/parser.ts +128 -0
  151. package/server/calculator/provider.ts +10 -0
  152. package/server/controllers/kpi-metric-value-provider.ts +66 -0
  153. package/server/controllers/kpi-value-provider.ts +51 -0
  154. package/server/service/index.ts +5 -0
  155. package/server/service/kpi/aggregate-kpi.ts +4 -4
  156. package/server/service/kpi/kpi-grade.types.ts +11 -10
  157. package/server/service/kpi/kpi-history.ts +2 -2
  158. package/server/service/kpi/kpi-mutation.ts +128 -4
  159. package/server/service/kpi/kpi-type.ts +21 -9
  160. package/server/service/kpi/kpi.ts +32 -10
  161. package/server/service/kpi-category/kpi-category-mutation.ts +155 -82
  162. package/server/service/kpi-category/kpi-category-query.ts +21 -1
  163. package/server/service/kpi-category/kpi-category-type.ts +17 -6
  164. package/server/service/kpi-category/kpi-category.ts +10 -1
  165. package/server/service/kpi-category-value/index.ts +7 -0
  166. package/server/service/kpi-category-value/kpi-category-value-mutation.ts +88 -0
  167. package/server/service/kpi-category-value/kpi-category-value-query.ts +62 -0
  168. package/server/service/kpi-category-value/kpi-category-value-type.ts +48 -0
  169. package/server/service/kpi-category-value/kpi-category-value.ts +79 -0
  170. package/server/service/kpi-metric/kpi-metric-type.ts +7 -5
  171. package/server/service/kpi-metric/kpi-metric.ts +3 -15
  172. package/server/service/kpi-metric-value/kpi-metric-value-mutation.ts +95 -47
  173. package/server/service/kpi-metric-value/kpi-metric-value.ts +4 -2
  174. package/server/service/kpi-value/kpi-value-mutation.ts +176 -6
  175. package/server/service/kpi-value/kpi-value-query.ts +2 -8
  176. package/server/service/kpi-value/kpi-value-score.service.ts +112 -0
  177. package/server/service/kpi-value/kpi-value-type.ts +12 -0
  178. package/server/service/kpi-value/kpi-value.ts +8 -1
  179. package/server/service/utils/value-date-util.ts +72 -0
  180. package/things-factory.config.js +3 -0
  181. package/translations/en.json +3 -0
  182. package/translations/ja.json +3 -0
  183. package/translations/ko.json +3 -0
  184. package/translations/ms.json +3 -0
  185. package/translations/zh.json +3 -0
  186. package/dist-server/service/kpi-value/kpi-value-grade.service.d.ts +0 -34
  187. package/dist-server/service/kpi-value/kpi-value-grade.service.js +0 -117
  188. package/dist-server/service/kpi-value/kpi-value-grade.service.js.map +0 -1
  189. package/server/service/kpi-value/kpi-value-grade.service.ts +0 -127
@@ -0,0 +1,404 @@
1
+ import '@material/web/icon/icon.js'
2
+ import '@material/web/button/elevated-button.js'
3
+ import '@operato/data-grist/ox-grist.js'
4
+ import '@operato/data-grist/ox-filters-form.js'
5
+ import '@operato/data-grist/ox-record-creator.js'
6
+
7
+ import { CommonButtonStyles, CommonHeaderStyles, CommonGristStyles, ScrollbarStyles } from '@operato/styles'
8
+ import { PageView, store } from '@operato/shell'
9
+ import { css, html } from 'lit'
10
+ import { customElement, property, query } from 'lit/decorators.js'
11
+ import { ScopedElementsMixin } from '@open-wc/scoped-elements'
12
+ import { ColumnConfig, DataGrist, FetchOption } from '@operato/data-grist'
13
+ import { client } from '@operato/graphql'
14
+ import { i18next, localize } from '@operato/i18n'
15
+ import { notify, openPopup } from '@operato/layout'
16
+ import { OxPopup, OxPrompt } from '@operato/popup'
17
+ import { isMobileDevice } from '@operato/utils'
18
+
19
+ import { connect } from 'pwa-helpers/connect-mixin'
20
+ import gql from 'graphql-tag'
21
+
22
+ @customElement('kpi-category-value-list-page')
23
+ export class KpiCategoryValueListPage extends connect(store)(localize(i18next)(ScopedElementsMixin(PageView))) {
24
+ static styles = [
25
+ ScrollbarStyles,
26
+ CommonGristStyles,
27
+ CommonHeaderStyles,
28
+ css`
29
+ :host {
30
+ display: flex;
31
+
32
+ width: 100%;
33
+
34
+ --grid-record-emphasized-background-color: #8b0000;
35
+ --grid-record-emphasized-color: #ff6b6b;
36
+ }
37
+
38
+ ox-grist {
39
+ overflow-y: auto;
40
+ flex: 1;
41
+ }
42
+
43
+ ox-filters-form {
44
+ flex: 1;
45
+ }
46
+ `
47
+ ]
48
+
49
+ @property({ type: Object }) gristConfig: any
50
+ @property({ type: String }) mode: 'CARD' | 'GRID' | 'LIST' = isMobileDevice() ? 'CARD' : 'GRID'
51
+
52
+ @query('ox-grist') private grist!: DataGrist
53
+
54
+ get context() {
55
+ return {
56
+ title: i18next.t('title.kpi category value list'),
57
+ search: {
58
+ handler: (search: string) => {
59
+ this.grist.searchText = search
60
+ },
61
+ value: this.grist.searchText
62
+ },
63
+ filter: {
64
+ handler: () => {
65
+ this.grist.toggleHeadroom()
66
+ }
67
+ },
68
+ help: 'kpi/kpi-category-value',
69
+ actions: [
70
+ {
71
+ title: i18next.t('button.save'),
72
+ action: this._updateKpiCategoryValue.bind(this),
73
+ ...CommonButtonStyles.save
74
+ },
75
+ {
76
+ title: i18next.t('button.delete'),
77
+ action: this._deleteKpiCategoryValue.bind(this),
78
+ ...CommonButtonStyles.delete
79
+ }
80
+ ],
81
+ exportable: {
82
+ name: i18next.t('title.kpi category value list'),
83
+ data: this.exportHandler.bind(this)
84
+ },
85
+ importable: {
86
+ handler: this.importHandler.bind(this)
87
+ }
88
+ }
89
+ }
90
+
91
+ render() {
92
+ const mode = this.mode || (isMobileDevice() ? 'CARD' : 'GRID')
93
+
94
+ return html`
95
+ <ox-grist .mode=${mode} .config=${this.gristConfig} .fetchHandler=${this.fetchHandler.bind(this)}>
96
+ <div slot="headroom" class="header">
97
+ <div class="filters">
98
+ <ox-filters-form autofocus without-search></ox-filters-form>
99
+
100
+ <div id="modes">
101
+ <md-icon @click=${() => (this.mode = 'GRID')} ?active=${mode == 'GRID'}>grid_on</md-icon>
102
+ <md-icon @click=${() => (this.mode = 'LIST')} ?active=${mode == 'LIST'}>format_list_bulleted</md-icon>
103
+ <md-icon @click=${() => (this.mode = 'CARD')} ?active=${mode == 'CARD'}>apps</md-icon>
104
+ </div>
105
+
106
+ <ox-record-creator id="add" .callback=${this.creationCallback.bind(this)}>
107
+ <button>
108
+ <md-icon>add</md-icon>
109
+ </button>
110
+ </ox-record-creator>
111
+ </div>
112
+ </div>
113
+ </ox-grist>
114
+ `
115
+ }
116
+
117
+ async pageInitialized(lifecycle: any) {
118
+ this.gristConfig = {
119
+ list: {
120
+ fields: ['category', 'valueDate', 'score', 'group', 'createdAt', 'updatedAt', 'creator', 'updater'],
121
+ details: ['category', 'valueDate', 'score', 'group', 'createdAt', 'updatedAt', 'creator', 'updater']
122
+ },
123
+ columns: [
124
+ { type: 'gutter', gutterName: 'sequence' },
125
+ { type: 'gutter', gutterName: 'row-selector', multiple: true },
126
+ // KPI Category Value 계산 버튼 추가
127
+ {
128
+ type: 'gutter',
129
+ gutterName: 'button',
130
+ icon: 'calculate',
131
+ title: '계산',
132
+ handlers: {
133
+ click: (columns, data, column, record, rowIndex) => {
134
+ this._calculateKpiCategoryValue(record)
135
+ }
136
+ }
137
+ },
138
+ {
139
+ type: 'string',
140
+ name: 'category',
141
+ header: '카테고리',
142
+ record: { editable: false, renderer: (v, c, r) => r.category?.name },
143
+ width: 150
144
+ },
145
+ { type: 'string', name: 'valueDate', header: '실적일', record: { editable: true }, width: 120 },
146
+ { type: 'number', name: 'score', header: '성과점수', record: { editable: false }, width: 120 },
147
+ { type: 'string', name: 'group', header: '그룹', record: { editable: false }, width: 120 },
148
+ { type: 'datetime', name: 'createdAt', header: '생성일', record: { editable: false }, width: 180 },
149
+ { type: 'datetime', name: 'updatedAt', header: '수정일', record: { editable: false }, width: 180 },
150
+ {
151
+ type: 'resource-object',
152
+ name: 'creator',
153
+ header: '생성자',
154
+ record: { editable: false, renderer: (v, c, r) => r.creator?.name },
155
+ width: 120
156
+ },
157
+ {
158
+ type: 'resource-object',
159
+ name: 'updater',
160
+ header: '수정자',
161
+ record: { editable: false, renderer: (v, c, r) => r.updater?.name },
162
+ width: 120
163
+ }
164
+ ]
165
+ }
166
+ }
167
+
168
+ async pageUpdated(changes: any, lifecycle: any) {
169
+ if (changes.has('mode')) {
170
+ this.grist.mode = this.mode
171
+ }
172
+ }
173
+
174
+ async fetchHandler({ page = 1, limit = 100, sortings = [], filters = [] }: FetchOption) {
175
+ const response = await client.query({
176
+ query: gql`
177
+ query ($filters: [Filter!], $pagination: Pagination, $sortings: [Sorting!]) {
178
+ responses: kpiCategoryValues(filters: $filters, pagination: $pagination, sortings: $sortings) {
179
+ items {
180
+ id
181
+ category {
182
+ id
183
+ name
184
+ }
185
+ valueDate
186
+ score
187
+ group
188
+ updater {
189
+ id
190
+ name
191
+ }
192
+ updatedAt
193
+ creator {
194
+ id
195
+ name
196
+ }
197
+ createdAt
198
+ }
199
+ total
200
+ }
201
+ }
202
+ `,
203
+ variables: {
204
+ filters,
205
+ pagination: { page, limit },
206
+ sortings
207
+ }
208
+ })
209
+
210
+ return {
211
+ total: response.data.responses.total || 0,
212
+ records: response.data.responses.items || []
213
+ }
214
+ }
215
+
216
+ async _deleteKpiCategoryValue() {
217
+ if (
218
+ await OxPrompt.open({
219
+ title: i18next.t('text.are_you_sure'),
220
+ text: i18next.t('text.sure_to_x', { x: i18next.t('text.delete') }),
221
+ confirmButton: { text: i18next.t('button.confirm') },
222
+ cancelButton: { text: i18next.t('button.cancel') }
223
+ })
224
+ ) {
225
+ const ids = this.grist.selected.map(record => record.id)
226
+ if (ids && ids.length > 0) {
227
+ const response = await client.mutate({
228
+ mutation: gql`
229
+ mutation ($ids: [String!]!) {
230
+ deleteKpiCategoryValues(ids: $ids)
231
+ }
232
+ `,
233
+ variables: {
234
+ ids
235
+ }
236
+ })
237
+
238
+ if (!response.errors) {
239
+ this.grist.fetch()
240
+ notify({
241
+ message: i18next.t('text.info_x_successfully', { x: i18next.t('text.delete') })
242
+ })
243
+ }
244
+ }
245
+ }
246
+ }
247
+
248
+ async _updateKpiCategoryValue() {
249
+ let patches = this.grist.dirtyRecords
250
+ if (patches && patches.length) {
251
+ patches = patches.map(patch => {
252
+ let patchField: any = patch.id ? { id: patch.id } : {}
253
+ const dirtyFields = patch.__dirtyfields__
254
+ for (let key in dirtyFields) {
255
+ patchField[key] = dirtyFields[key].after
256
+ }
257
+ patchField.cuFlag = patch.__dirty__
258
+
259
+ return patchField
260
+ })
261
+
262
+ const response = await client.mutate({
263
+ mutation: gql`
264
+ mutation ($patches: [KpiCategoryValuePatch!]!) {
265
+ updateMultipleKpiCategoryValue(patches: $patches) {
266
+ id
267
+ category {
268
+ id
269
+ name
270
+ }
271
+ valueDate
272
+ score
273
+ group
274
+ updater {
275
+ id
276
+ name
277
+ }
278
+ updatedAt
279
+ creator {
280
+ id
281
+ name
282
+ }
283
+ createdAt
284
+ }
285
+ }
286
+ `,
287
+ variables: {
288
+ patches
289
+ }
290
+ })
291
+
292
+ if (!response.errors) {
293
+ this.grist.fetch()
294
+ notify({
295
+ message: i18next.t('text.info_x_successfully', { x: i18next.t('text.save') })
296
+ })
297
+ }
298
+ }
299
+ }
300
+
301
+ async _calculateKpiCategoryValue(kpiCategoryValue) {
302
+ try {
303
+ const response = await client.mutate({
304
+ mutation: gql`
305
+ mutation ($categoryId: String!, $valueDate: String, $group: String) {
306
+ calculateKpiValue(categoryId: $categoryId, valueDate: $valueDate, group: $group) {
307
+ score
308
+ valueDate
309
+ group
310
+ }
311
+ }
312
+ `,
313
+ variables: {
314
+ categoryId: kpiCategoryValue.category.id,
315
+ valueDate: kpiCategoryValue.valueDate,
316
+ group: kpiCategoryValue.group
317
+ }
318
+ })
319
+
320
+ if (!response.errors) {
321
+ const result = response.data.calculateKpiValue
322
+
323
+ // 팝업으로 결과 표시
324
+ await openPopup(html`
325
+ <div style="padding: 20px;">
326
+ <h3>KPI Category Value 계산 결과</h3>
327
+ <p><strong>성과점수:</strong> ${result.score || 'N/A'}</p>
328
+ <p><strong>실적일:</strong> ${result.valueDate || 'N/A'}</p>
329
+ <p><strong>그룹:</strong> ${result.group || 'N/A'}</p>
330
+ </div>
331
+ `)
332
+
333
+ // 목록 새로고침
334
+ this.grist.fetch()
335
+
336
+ notify({
337
+ message: 'KPI Category Value 계산이 완료되었습니다.'
338
+ })
339
+ }
340
+ } catch (error) {
341
+ console.error('KPI Category Value 계산 중 오류:', error)
342
+ notify({
343
+ message: 'KPI Category Value 계산 중 오류가 발생했습니다.'
344
+ })
345
+ }
346
+ }
347
+
348
+ async creationCallback(kpiCategoryValue) {
349
+ const response = await client.mutate({
350
+ mutation: gql`
351
+ mutation ($kpiCategoryValue: NewKpiCategoryValue!) {
352
+ createKpiCategoryValue(kpiCategoryValue: $kpiCategoryValue) {
353
+ id
354
+ category {
355
+ id
356
+ name
357
+ }
358
+ valueDate
359
+ score
360
+ group
361
+ updater {
362
+ id
363
+ name
364
+ }
365
+ updatedAt
366
+ creator {
367
+ id
368
+ name
369
+ }
370
+ createdAt
371
+ }
372
+ }
373
+ `,
374
+ variables: {
375
+ kpiCategoryValue
376
+ }
377
+ })
378
+
379
+ if (!response.errors) {
380
+ this.grist.fetch()
381
+ notify({
382
+ message: i18next.t('text.info_x_successfully', { x: i18next.t('text.create') })
383
+ })
384
+ }
385
+ }
386
+
387
+ async exportHandler() {
388
+ // 임시로 빈 배열 반환
389
+ return []
390
+ }
391
+
392
+ async importHandler(records) {
393
+ const kpiCategoryValues = records.map(record => ({
394
+ categoryId: record.category?.id || record.category,
395
+ valueDate: record.valueDate,
396
+ score: record.score,
397
+ group: record.group
398
+ }))
399
+
400
+ for (const kpiCategoryValue of kpiCategoryValues) {
401
+ await this.creationCallback(kpiCategoryValue)
402
+ }
403
+ }
404
+ }
@@ -194,7 +194,19 @@ export class KpiMetricListPage extends connect(store)(localize(i18next)(ScopedEl
194
194
  type: 'select',
195
195
  name: 'periodType',
196
196
  header: '주기',
197
- record: { editable: true, options: ['', 'DAY', 'WEEK', 'MONTH', 'QUARTER', 'YEAR', 'RANGE'] },
197
+ record: {
198
+ editable: true,
199
+ options: [
200
+ { value: '', display: '' },
201
+ { value: 'DAY', display: '일' },
202
+ { value: 'WEEK', display: '주' },
203
+ { value: 'MONTH', display: '월' },
204
+ { value: 'QUARTER', display: '분기' },
205
+ { value: 'YEAR', display: '년' },
206
+ { value: 'RANGE', display: '범위' },
207
+ { value: 'ALLTIME', display: '전체' }
208
+ ]
209
+ },
198
210
  width: 80
199
211
  },
200
212
  { type: 'checkbox', name: 'active', label: true, header: '활성', record: { editable: true }, width: 60 },