From b2a0f1cde21684445288e0f247d957e5facbf615 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nguyen=20Van=20Luan/=28Nguyen=20Van=20Luan=29/=ED=98=84?= =?UTF-8?q?=EC=9E=A5=EB=8C=80=EB=A6=AC=EC=9D=B8/SK?= <20074472@skcc.com> Date: Tue, 26 Aug 2025 17:28:37 +0900 Subject: [PATCH] update code --- assets/scss/common/input.scss | 2 +- components/common/AdminMenu.vue | 10 +- components/common/modal/ChangePswdPop.vue | 1 - components/common/modal/EvtObjPop.vue | 2 +- .../ems/ReadObjInfo/ReadObjAddInfoTab.vue | 4 +- pages/ems/effc/DataSetMngPage.vue | 3 + plugins/gridUtility.js | 157 +++++++++++++++++- 7 files changed, 168 insertions(+), 11 deletions(-) diff --git a/assets/scss/common/input.scss b/assets/scss/common/input.scss index 8e7bf76..658f947 100644 --- a/assets/scss/common/input.scss +++ b/assets/scss/common/input.scss @@ -1,5 +1,5 @@ .v-select__custom { - padding: 0.125rem; + // padding: 0.125rem; &.v-text-field.v-text-field--solo:not(.v-text-field--solo-flat)>.v-input__control>.v-input__slot { box-shadow: none; diff --git a/components/common/AdminMenu.vue b/components/common/AdminMenu.vue index 96b3806..7cea308 100644 --- a/components/common/AdminMenu.vue +++ b/components/common/AdminMenu.vue @@ -43,16 +43,16 @@ - + mdi-account-outline 비밀번호 변경 - + - + mdi-logout 로그아웃 - + @@ -105,7 +105,7 @@ export default { }); }, pswdChange() { - this.$parent.$parent.$parent.$parent.$refs['changePswdPop'].dialog = true; + this.$parent.$parent.$parent.$refs['changePswdPop'].dialog = true; }, }, mounted() {}, diff --git a/components/common/modal/ChangePswdPop.vue b/components/common/modal/ChangePswdPop.vue index 6158428..49eede8 100644 --- a/components/common/modal/ChangePswdPop.vue +++ b/components/common/modal/ChangePswdPop.vue @@ -104,7 +104,6 @@ export default { }, watch: { async chkDialog(val) { - //console.log("watch : ", val) if (val) { this.openDialog(); diff --git a/components/common/modal/EvtObjPop.vue b/components/common/modal/EvtObjPop.vue index c81bf97..f10fa09 100644 --- a/components/common/modal/EvtObjPop.vue +++ b/components/common/modal/EvtObjPop.vue @@ -53,7 +53,7 @@ -
+
diff --git a/components/pages/ems/ReadObjInfo/ReadObjAddInfoTab.vue b/components/pages/ems/ReadObjInfo/ReadObjAddInfoTab.vue index b4f5f7d..3f2f8a3 100644 --- a/components/pages/ems/ReadObjInfo/ReadObjAddInfoTab.vue +++ b/components/pages/ems/ReadObjInfo/ReadObjAddInfoTab.vue @@ -33,6 +33,7 @@ import Form from '~/components/common/form/Form'; import mixinGlobal from '@/mixin/global.js'; import { NewCustomRenderer } from '~/plugins/gridUtility'; import { NewCustomEditor } from '~/plugins/gridUtility'; +import { CustomEditorCheckbox } from '~/plugins/gridUtility'; export default { mixins: [mixinGlobal], components: { @@ -122,7 +123,6 @@ export default { gridKey: this.gridName, value: myOptions, }); - const _this = this; let useFgSelectList = []; this.pageData.useFgList.forEach(item => { @@ -310,7 +310,7 @@ export default { type: NewCustomRenderer, }, editor: { - type: NewCustomEditor, + type: CustomEditorCheckbox, }, formatter(data) { return data.row.addInfoDataKind; diff --git a/pages/ems/effc/DataSetMngPage.vue b/pages/ems/effc/DataSetMngPage.vue index bb2c501..274a229 100644 --- a/pages/ems/effc/DataSetMngPage.vue +++ b/pages/ems/effc/DataSetMngPage.vue @@ -783,5 +783,8 @@ const dataPathDataExample = getPathDataExample({ .v-window { overflow: visible; } + .ant-checkbox-inner { + padding: 8px; + } } diff --git a/plugins/gridUtility.js b/plugins/gridUtility.js index e39230e..c63c65f 100644 --- a/plugins/gridUtility.js +++ b/plugins/gridUtility.js @@ -401,4 +401,159 @@ export class NewCustomEditor { // } this.el.select(); } -} \ No newline at end of file +} + +export class CustomEditorCheckbox { + + constructor(props) { + + const { grid, rowKey, columnInfo } = props; + + this.grid = grid; + this.rowKey = rowKey; + this.columnInfo = columnInfo; + + const origin = grid?.dataManager?.getOriginData?.() || grid?.dataManager?.originData || []; + + this.gridOriginData = origin; + + const wrap = document.createElement('div'); + wrap.className = 'tui-grid-cell-content'; + wrap.style.height = '100%'; + wrap.style.display = 'flex'; + wrap.style.justifyContent = 'center'; + + const input = document.createElement('input'); + const rowRaw = props.grid.store.data.rawData[props.rowKey] || {}; + const isFG = rowRaw.addInfoDataKind == 'FG'; + const isNUM = props.formattedValue === 'NUM'; + + if (isFG) { + + input.type = 'checkbox'; + input.checked = String(props.value) === '1'; + input.value = input.checked ? '1' : '0'; + + wrap.style.position = 'relative'; + wrap.style.top = rowKey === 0 ? '1px' : '3px'; + + input.addEventListener('change', (ev) => { + const checked = ev.target.checked; + ev.target.value = checked ? '1' : '0'; + + if (!checked) { + const rowOrigin = this.gridOriginData[this.rowKey]; + const originValRaw = rowOrigin ? rowOrigin[this.columnInfo.name] : null; + const originVal = normalizeVal(originValRaw); + if (originVal !== '1') { + ev.target.value = originVal ?? '0'; + } + } + this._updateRowChangeState(ev.target.value); + + }); + + } else { + // Text input + input.type = 'text'; + input.autocomplete = 'off'; + input.spellcheck = false; + + if (isNUM) { + const filterToDigits = (el) => { + const before = el.value; + const after = before.replace(/[^0-9]/g, ''); + if (before !== after) el.value = after; + }; + + input.addEventListener('input', () => filterToDigits(input)); + input.addEventListener('blur', () => filterToDigits(input)); + + input.addEventListener('drop', (e) => { + e.preventDefault(); + const text = (e.dataTransfer.getData('text') || '').replace(/[^0-9]/g, ''); + const { selectionStart, selectionEnd } = input; + const val = input.value; + input.value = val.slice(0, selectionStart) + text + val.slice(selectionEnd); + this._updateRowChangeState(input.value); + }); + + input.addEventListener('paste', (e) => { + e.preventDefault(); + const text = (e.clipboardData.getData('text') || '').replace(/[^0-9]/g, ''); + const { selectionStart, selectionEnd } = input; + const val = input.value; + input.value = val.slice(0, selectionStart) + text + val.slice(selectionEnd); + this._updateRowChangeState(input.value); + }); + } + wrap.style.justifyContent = 'flex-start'; + input.style.width = '100%'; + input.style.boxSizing = 'border-box'; + + } + + wrap.appendChild(input); + this.divEl = wrap; + this.el = input; + this.render(props); + + function normalizeVal(v) { + if (v === true) return '1'; + if (v === false) return '0'; + if (v == null) return null; + + const s = String(v).trim(); + if (s === '1' || s === '0') return s; + return s; + } + + this._normalizeVal = normalizeVal; + + } + + getElement() { + return this.divEl; + } + + getValue() { + if (this.el.type === 'checkbox') { + return this.el.checked ? '1' : '0'; + } + return this.el.value; + } + + render(props) { + if (this.el.type === 'checkbox') { + const isOne = String(props.value) === '1'; + this.el.checked = isOne; + this.el.value = isOne ? '1' : '0'; + } else { + this.el.value = props.value != null ? String(props.value) : ''; + } + } + + mounted() { + if (this.el.type !== 'checkbox') { + try { this.el.select(); } catch {} + } + } + + _updateRowChangeState(changedRaw) { + + const changed = this._normalizeVal(changedRaw); + const rowOrigin = this.gridOriginData[this.rowKey]; + const originRaw = rowOrigin ? rowOrigin[this.columnInfo.name] : null; + const origin = this._normalizeVal(originRaw); + + if (origin === changed || (origin == null && (changed === '' || changed == null))) { + this.grid.removeRowClassName(this.rowKey, 'row-insert'); + this.grid.setValue(this.rowKey, 'rowStat', null); + } else { + this.grid.setValue(this.rowKey, 'rowStat', 'U'); + this.grid.addRowClassName(this.rowKey, 'row-insert'); + } + + } + + } \ No newline at end of file