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