Skip to content

Commit 4b21df1

Browse files
author
Kenneth Cheng
committed
hide duplication 1.0.43
1 parent 37c9ada commit 4b21df1

File tree

3 files changed

+19
-16
lines changed

3 files changed

+19
-16
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.42",
5+
"version": "1.0.43",
66
"main": "src/main.js",
77
"dependencies": {
88
"@vuepic/vue-datepicker": "^3.3.0",

src/VueExcelEditor.vue

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -125,8 +125,8 @@
125125
:style="Object.assign(cellStyle(record, item), renderColumnCellStyle(item, record))"
126126
@mouseover="cellMouseOver"
127127
@mousemove="cellMouseMove">
128-
<template v-if="item.format=='html'"><span v-html="item.toText(record[item.name])" /></template>
129-
<template v-else>{{ item.toText(record[item.name]) }}</template>
128+
<template v-if="item.format=='html'"><span v-html="item.toText(record[item.name], record, item)" /></template>
129+
<template v-else>{{ item.toText(record[item.name], record, item) }}</template>
130130
</td>
131131
<td v-if="vScroller.buttonHeight < vScroller.height" class="last-col"></td>
132132
</tr>
@@ -1703,26 +1703,26 @@ export default defineComponent({
17031703
const field = this.fields[colPos]
17041704
const name = field.name
17051705
setTimeout(() => {
1706-
let sorting = field.sort
1706+
let sorting = field.sorting
17071707
if (sorting === null) {
17081708
if (field.type === 'number')
17091709
sorting = (a, b) => {
1710-
if (Number(a[name]) > Number(b[name])) return 1
1711-
if (Number(a[name]) < Number(b[name])) return -1
1710+
if (Number(a) > Number(b)) return 1
1711+
if (Number(a) < Number(b)) return -1
17121712
return 0
17131713
}
17141714
else
1715-
sorting = (a, b) => {
1716-
return String(a[name]).localeCompare(String(b[name]))
1717-
}
1715+
sorting = (a, b) => {
1716+
return String(a).localeCompare(String(b))
1717+
}
17181718
}
17191719
this.modelValue.sort((a, b) => {
1720-
return sorting(a, b) * -n
1720+
if (field.sort) return field.sort(a, b) * -n
1721+
else return sorting(a[name], b[name]) * -n
17211722
})
17221723
this.sortPos = colPos
17231724
this.sortDir = n
17241725
this.refresh()
1725-
// this.$forceUpdate()
17261726
this.processing = false
17271727
}, 0)
17281728
},
@@ -2492,9 +2492,9 @@ export default defineComponent({
24922492
if (typeof colPos !== 'undefined') field = this.fields[colPos]
24932493
if (typeof recPos === 'undefined') recPos = this.pageTop + this.currentRowPos
24942494
if (typeof this.selected[recPos] !== 'undefined')
2495-
this.updateSelectedRows(field, field.toValue(setText))
2495+
this.updateSelectedRows(field, setText)
24962496
else
2497-
this.updateCell(recPos, field, field.toValue(setText))
2497+
this.updateCell(recPos, field, field.toValue(setText, this.table[recPos], field))
24982498
},
24992499
inputBoxBlur () {
25002500
if (!this.$refs.dpContainer) return
@@ -2668,10 +2668,13 @@ export default defineComponent({
26682668
}, 50)
26692669
})
26702670
},
2671-
updateSelectedRows (field, content) {
2671+
updateSelectedRows (field, setText) {
26722672
this.processing = true
26732673
setTimeout(() => {
2674-
Object.keys(this.selected).forEach(recPos => this.updateCell(parseInt(recPos), field, content))
2674+
Object.keys(this.selected).forEach(recPos => {
2675+
const pos = parseInt(recPos)
2676+
this.updateCell(pos, field, field.toValue(setText, this.table[pos], field))
2677+
})
26752678
this.processing = false
26762679
}, 0)
26772680
},

0 commit comments

Comments
 (0)