Skip to content

Commit eea1ac3

Browse files
author
Kenneth Cheng
committed
Fix the bug in currentField
1 parent 92921ef commit eea1ac3

File tree

3 files changed

+17
-17
lines changed

3 files changed

+17
-17
lines changed

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "vue3-excel-editor",
33
"email": "apple.6502@gmail.com",
44
"description": "Vue3 plugin for displaying and editing the array-of-object in Excel style",
5-
"version": "1.0.33",
5+
"version": "1.0.34",
66
"main": "src/main.js",
77
"dependencies": {
88
"@vuepic/vue-datepicker": "^3.3.0",

src/VueExcelEditor.vue

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@
7070
:style="{top: calCellTop2 + 'px'}"
7171
@click="columnFilter = {}">
7272
<span v-if="Object.keys(columnFilter).length > 0">
73-
<svg aria-hidden="true" focusable="false" data-prefix="fas" data-icon="eraser" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512" class="svg-inline--fa fa-eraser fa-w-16 fa-sm"><path fill="currentColor" d="M497.941 273.941c18.745-18.745 18.745-49.137 0-67.882l-160-160c-18.745-18.745-49.136-18.746-67.883 0l-256 256c-18.745 18.745-18.745 49.137 0 67.882l96 96A48.004 48.004 0 0 0 144 480h356c6.627 0 12-5.373 12-12v-40c0-6.627-5.373-12-12-12H355.883l142.058-142.059zm-302.627-62.627l137.373 137.373L265.373 416H150.628l-80-80 124.686-124.686z"></path></svg>
73+
<svg aria-hidden="true" focusable="false" data-prefix="fas" data-icon="eraser" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512" class="svg-inline--fa fa-eraser fa-w-16 fa-sm"><path fill="currentColor" d="M497.941 273.941c18.745-18.745 18.745-49.137 0-67.882l-160-160c-18.745-18.745-49.136-18.746-67.883 0l-256 256c-18.745 18.745-18.745 49.137 0 67.882l96 96A48.004 48.004 0 0 0 144 480h356c6.627 0 12-5.373 12-12v-40c0-6.627-5.373-12-12-12H355.883l142.058-142.059zm-302.627-62.627l137.373 137.373L265.373 416H150.628l-80-80 124.686-124.686z"></path></svg>
7474
</span>
7575
<!--
7676
<svg v-if="selectedCount==table.length" aria-hidden="true" focusable="false" data-prefix="fas" data-icon="times-circle" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512" class="svg-inline--fa fa-times-circle fa-w-16 fa-sm"><path fill="currentColor" d="M256 8C119 8 8 119 8 256s111 248 248 248 248-111 248-248S393 8 256 8zm121.6 313.1c4.7 4.7 4.7 12.3 0 17L338 377.6c-4.7 4.7-12.3 4.7-17 0L256 312l-65.1 65.6c-4.7 4.7-12.3 4.7-17 0L134.4 338c-4.7-4.7-4.7-12.3 0-17l65.6-65-65.6-65.1c-4.7-4.7-4.7-12.3 0-17l39.6-39.6c4.7-4.7 12.3-4.7 17 0l65 65.7 65.1-65.6c4.7-4.7 12.3-4.7 17 0l39.6 39.6c4.7 4.7 4.7 12.3 0 17L312 256l65.6 65.1z"></path></svg>
@@ -700,7 +700,7 @@ export default defineComponent({
700700
register: null
701701
}
702702
if (this.addColumn) colDef = this.addColumn(colDef)
703-
this.newColumn(colDef, pos)
703+
this.newColumn(colDef, pos)
704704
},
705705
newColumn (field, pos) {
706706
this.fields.splice(pos, 0, field)
@@ -743,7 +743,7 @@ export default defineComponent({
743743
toText: t => t,
744744
register: null
745745
})
746-
})
746+
})
747747
},
748748
refresh () {
749749
// this.pageTop = 0
@@ -912,7 +912,7 @@ export default defineComponent({
912912
},
913913
localeDate (d) {
914914
if (typeof d === 'undefined') d = new Date()
915-
const pad = n => n < 10 ? '0'+n : n;
915+
const pad = n => n < 10 ? '0'+n : n;
916916
return d.getFullYear() + '-'
917917
+ pad(d.getMonth() + 1) + '-'
918918
+ pad(d.getDate()) + ' '
@@ -1004,7 +1004,7 @@ export default defineComponent({
10041004
ref.$el.textContent = filterText
10051005
ref.$emit('update:modelValue', filterText)
10061006
},
1007-
1007+
10081008
clearFilter(name) {
10091009
if (!name) this.columnFilter = {}
10101010
else this.setFilter(name, '')
@@ -1810,7 +1810,7 @@ export default defineComponent({
18101810
},
18111811
18121812
settingClick() {
1813-
if (!this.disablePanelSetting)
1813+
if (!this.disablePanelSetting)
18141814
this.$refs.panelSetting.showPanel();
18151815
},
18161816
@@ -1825,7 +1825,7 @@ export default defineComponent({
18251825
this.$refs.importFile.click()
18261826
this.importCallback = cb
18271827
this.importErrorCallback = errCb
1828-
},
1828+
},
18291829
doImport (e) {
18301830
this.processing = true
18311831
// this.refresh()
@@ -1875,8 +1875,8 @@ export default defineComponent({
18751875
if (keys.length) {
18761876
// locate match record
18771877
rowPos = this.table.findIndex(v =>
1878-
keys.filter(f =>
1879-
typeof v[f.name] !== 'undefined'
1878+
keys.filter(f =>
1879+
typeof v[f.name] !== 'undefined'
18801880
&& (v[f.name] === line[f.name] || v[f.name] === line[f.label])).length === keys.length
18811881
)
18821882
if (rowPos === -1) {
@@ -1979,7 +1979,7 @@ export default defineComponent({
19791979
throw new Error('VueExcelEditor: ' + e.stack)
19801980
}
19811981
fileReader.readAsBinaryString(file)
1982-
}, 500)
1982+
}, 500)
19831983
},
19841984
exportTable (format, selectedOnly, filename) {
19851985
this.processing = true
@@ -2100,7 +2100,7 @@ export default defineComponent({
21002100
}
21012101
},
21022102
selectRecordByKeys (keys) {
2103-
const rowPos = this.table.findIndex(v =>
2103+
const rowPos = this.table.findIndex(v =>
21042104
this.fields.filter(f => f.keyField).filter(f => v[f.name] === keys[f.name]).length === keys.length)
21052105
if (rowPos >= 0) this.selectRecord(rowPos)
21062106
},
@@ -2296,15 +2296,15 @@ export default defineComponent({
22962296
if (e.target.offsetWidth < e.target.scrollWidth)
22972297
cursor = 'pointer'
22982298
}
2299-
if (this.currentField && this.currentField.type === 'action')
2299+
const row = e.target.parentNode
2300+
const colPos = Array.from(row.children).indexOf(e.target) - 1
2301+
const currentField = this.fields[colPos]
2302+
if (currentField.type === 'action')
23002303
cursor = 'pointer'
23012304
e.target.style.cursor = cursor
23022305
},
23032306
cellMouseOver (e) {
23042307
const cell = e.target
2305-
const row = e.target.parentNode
2306-
const colPos = Array.from(row.children).indexOf(e.target) - 1
2307-
this.currentField = this.fields[colPos]
23082308
if (!cell.classList.contains('error')) return
23092309
if (this.tipTimeout) clearTimeout(this.tipTimeout)
23102310
if ((this.tip = this.errmsg[cell.getAttribute('id')]) === '') return

0 commit comments

Comments
 (0)