|
@@ -57,7 +57,7 @@
|
|
|
<span style="font-weight: 500;">{{ row.name }}</span>
|
|
<span style="font-weight: 500;">{{ row.name }}</span>
|
|
|
</template>
|
|
</template>
|
|
|
<template slot="header">
|
|
<template slot="header">
|
|
|
- <span class="sort-header" @click.stop="onSortClick('name',$event)" @dblclick.stop="onSortToggle('name')">名称{{ sortIcon('name') }}</span>
|
|
|
|
|
|
|
+ <span class="sort-header" @click.stop="onSortClick('name',$event)" @dblclick.stop="onSortToggle('name')">名称<span v-if="sortIndex('name') !== null" class="sort-index" :class="sortClass('name') === 'sort-asc' ? 'sort-asc-badge' : 'sort-desc-badge'">{{ sortIndex('name') }}</span>{{ sortIcon('name') }}</span>
|
|
|
</template>
|
|
</template>
|
|
|
</el-table-column>
|
|
</el-table-column>
|
|
|
<el-table-column prop="category" label="分类" width="120" align="center" :class-name="sortClass('category')">
|
|
<el-table-column prop="category" label="分类" width="120" align="center" :class-name="sortClass('category')">
|
|
@@ -67,7 +67,7 @@
|
|
|
</el-tag>
|
|
</el-tag>
|
|
|
</template>
|
|
</template>
|
|
|
<template slot="header">
|
|
<template slot="header">
|
|
|
- <span class="sort-header" @click.stop="onSortClick('category',$event)" @dblclick.stop="onSortToggle('category')">分类{{ sortIcon('category') }}</span>
|
|
|
|
|
|
|
+ <span class="sort-header" @click.stop="onSortClick('category',$event)" @dblclick.stop="onSortToggle('category')">分类<span v-if="sortIndex('category') !== null" class="sort-index" :class="sortClass('category') === 'sort-asc' ? 'sort-asc-badge' : 'sort-desc-badge'">{{ sortIndex('category') }}</span>{{ sortIcon('category') }}</span>
|
|
|
</template>
|
|
</template>
|
|
|
</el-table-column>
|
|
</el-table-column>
|
|
|
<el-table-column label="热量" width="100" align="right" :class-name="sortClass('calories')">
|
|
<el-table-column label="热量" width="100" align="right" :class-name="sortClass('calories')">
|
|
@@ -76,7 +76,7 @@
|
|
|
<span class="num-unit">kcal</span>
|
|
<span class="num-unit">kcal</span>
|
|
|
</template>
|
|
</template>
|
|
|
<template slot="header">
|
|
<template slot="header">
|
|
|
- <span class="sort-header" @click.stop="onSortClick('calories',$event)" @dblclick.stop="onSortToggle('calories')">热量{{ sortIcon('calories') }}</span>
|
|
|
|
|
|
|
+ <span class="sort-header" @click.stop="onSortClick('calories',$event)" @dblclick.stop="onSortToggle('calories')">热量<span v-if="sortIndex('calories') !== null" class="sort-index" :class="sortClass('calories') === 'sort-asc' ? 'sort-asc-badge' : 'sort-desc-badge'">{{ sortIndex('calories') }}</span>{{ sortIcon('calories') }}</span>
|
|
|
</template>
|
|
</template>
|
|
|
</el-table-column>
|
|
</el-table-column>
|
|
|
<el-table-column label="蛋白质" width="90" align="right" :class-name="sortClass('protein')">
|
|
<el-table-column label="蛋白质" width="90" align="right" :class-name="sortClass('protein')">
|
|
@@ -85,7 +85,7 @@
|
|
|
<span class="num-unit">g</span>
|
|
<span class="num-unit">g</span>
|
|
|
</template>
|
|
</template>
|
|
|
<template slot="header">
|
|
<template slot="header">
|
|
|
- <span class="sort-header" @click.stop="onSortClick('protein',$event)" @dblclick.stop="onSortToggle('protein')">蛋白{{ sortIcon('protein') }}</span>
|
|
|
|
|
|
|
+ <span class="sort-header" @click.stop="onSortClick('protein',$event)" @dblclick.stop="onSortToggle('protein')">蛋白<span v-if="sortIndex('protein') !== null" class="sort-index" :class="sortClass('protein') === 'sort-asc' ? 'sort-asc-badge' : 'sort-desc-badge'">{{ sortIndex('protein') }}</span>{{ sortIcon('protein') }}</span>
|
|
|
</template>
|
|
</template>
|
|
|
</el-table-column>
|
|
</el-table-column>
|
|
|
<el-table-column label="脂肪" width="80" align="right" :class-name="sortClass('fat')">
|
|
<el-table-column label="脂肪" width="80" align="right" :class-name="sortClass('fat')">
|
|
@@ -94,7 +94,7 @@
|
|
|
<span class="num-unit">g</span>
|
|
<span class="num-unit">g</span>
|
|
|
</template>
|
|
</template>
|
|
|
<template slot="header">
|
|
<template slot="header">
|
|
|
- <span class="sort-header" @click.stop="onSortClick('fat',$event)" @dblclick.stop="onSortToggle('fat')">脂肪{{ sortIcon('fat') }}</span>
|
|
|
|
|
|
|
+ <span class="sort-header" @click.stop="onSortClick('fat',$event)" @dblclick.stop="onSortToggle('fat')">脂肪<span v-if="sortIndex('fat') !== null" class="sort-index" :class="sortClass('fat') === 'sort-asc' ? 'sort-asc-badge' : 'sort-desc-badge'">{{ sortIndex('fat') }}</span>{{ sortIcon('fat') }}</span>
|
|
|
</template>
|
|
</template>
|
|
|
</el-table-column>
|
|
</el-table-column>
|
|
|
<el-table-column label="碳水" width="80" align="right" :class-name="sortClass('carbs')">
|
|
<el-table-column label="碳水" width="80" align="right" :class-name="sortClass('carbs')">
|
|
@@ -103,7 +103,7 @@
|
|
|
<span class="num-unit">g</span>
|
|
<span class="num-unit">g</span>
|
|
|
</template>
|
|
</template>
|
|
|
<template slot="header">
|
|
<template slot="header">
|
|
|
- <span class="sort-header" @click.stop="onSortClick('carbs',$event)" @dblclick.stop="onSortToggle('carbs')">碳水{{ sortIcon('carbs') }}</span>
|
|
|
|
|
|
|
+ <span class="sort-header" @click.stop="onSortClick('carbs',$event)" @dblclick.stop="onSortToggle('carbs')">碳水<span v-if="sortIndex('carbs') !== null" class="sort-index" :class="sortClass('carbs') === 'sort-asc' ? 'sort-asc-badge' : 'sort-desc-badge'">{{ sortIndex('carbs') }}</span>{{ sortIcon('carbs') }}</span>
|
|
|
</template>
|
|
</template>
|
|
|
</el-table-column>
|
|
</el-table-column>
|
|
|
<el-table-column label="膳食纤维" width="90" align="right" :class-name="sortClass('fiber')">
|
|
<el-table-column label="膳食纤维" width="90" align="right" :class-name="sortClass('fiber')">
|
|
@@ -112,7 +112,7 @@
|
|
|
<span class="num-unit">g</span>
|
|
<span class="num-unit">g</span>
|
|
|
</template>
|
|
</template>
|
|
|
<template slot="header">
|
|
<template slot="header">
|
|
|
- <span class="sort-header" @click.stop="onSortClick('fiber',$event)" @dblclick.stop="onSortToggle('fiber')">纤维{{ sortIcon('fiber') }}</span>
|
|
|
|
|
|
|
+ <span class="sort-header" @click.stop="onSortClick('fiber',$event)" @dblclick.stop="onSortToggle('fiber')">纤维<span v-if="sortIndex('fiber') !== null" class="sort-index" :class="sortClass('fiber') === 'sort-asc' ? 'sort-asc-badge' : 'sort-desc-badge'">{{ sortIndex('fiber') }}</span>{{ sortIcon('fiber') }}</span>
|
|
|
</template>
|
|
</template>
|
|
|
</el-table-column>
|
|
</el-table-column>
|
|
|
<el-table-column label="能量(kJ)" width="90" align="right" :class-name="sortClass('energyKj')">
|
|
<el-table-column label="能量(kJ)" width="90" align="right" :class-name="sortClass('energyKj')">
|
|
@@ -120,7 +120,7 @@
|
|
|
<span class="num-val">{{ row.energyKj != null ? row.energyKj : '-' }}</span>
|
|
<span class="num-val">{{ row.energyKj != null ? row.energyKj : '-' }}</span>
|
|
|
</template>
|
|
</template>
|
|
|
<template slot="header">
|
|
<template slot="header">
|
|
|
- <span class="sort-header" @click.stop="onSortClick('energyKj',$event)" @dblclick.stop="onSortToggle('energyKj')">能量{{ sortIcon('energyKj') }}</span>
|
|
|
|
|
|
|
+ <span class="sort-header" @click.stop="onSortClick('energyKj',$event)" @dblclick.stop="onSortToggle('energyKj')">能量<span v-if="sortIndex('energyKj') !== null" class="sort-index" :class="sortClass('energyKj') === 'sort-asc' ? 'sort-asc-badge' : 'sort-desc-badge'">{{ sortIndex('energyKj') }}</span>{{ sortIcon('energyKj') }}</span>
|
|
|
</template>
|
|
</template>
|
|
|
</el-table-column>
|
|
</el-table-column>
|
|
|
<el-table-column label="胆固醇" width="90" align="right" :class-name="sortClass('cholesterol')">
|
|
<el-table-column label="胆固醇" width="90" align="right" :class-name="sortClass('cholesterol')">
|
|
@@ -129,7 +129,7 @@
|
|
|
<span v-else>-</span>
|
|
<span v-else>-</span>
|
|
|
</template>
|
|
</template>
|
|
|
<template slot="header">
|
|
<template slot="header">
|
|
|
- <span class="sort-header" @click.stop="onSortClick('cholesterol',$event)" @dblclick.stop="onSortToggle('cholesterol')">胆固醇{{ sortIcon('cholesterol') }}</span>
|
|
|
|
|
|
|
+ <span class="sort-header" @click.stop="onSortClick('cholesterol',$event)" @dblclick.stop="onSortToggle('cholesterol')">胆固醇<span v-if="sortIndex('cholesterol') !== null" class="sort-index" :class="sortClass('cholesterol') === 'sort-asc' ? 'sort-asc-badge' : 'sort-desc-badge'">{{ sortIndex('cholesterol') }}</span>{{ sortIcon('cholesterol') }}</span>
|
|
|
</template>
|
|
</template>
|
|
|
</el-table-column>
|
|
</el-table-column>
|
|
|
<el-table-column prop="status" label="状态" width="80" align="center" :class-name="sortClass('status')">
|
|
<el-table-column prop="status" label="状态" width="80" align="center" :class-name="sortClass('status')">
|
|
@@ -139,7 +139,7 @@
|
|
|
</el-tag>
|
|
</el-tag>
|
|
|
</template>
|
|
</template>
|
|
|
<template slot="header">
|
|
<template slot="header">
|
|
|
- <span class="sort-header" @click.stop="onSortClick('status',$event)" @dblclick.stop="onSortToggle('status')">状态{{ sortIcon('status') }}</span>
|
|
|
|
|
|
|
+ <span class="sort-header" @click.stop="onSortClick('status',$event)" @dblclick.stop="onSortToggle('status')">状态<span v-if="sortIndex('status') !== null" class="sort-index" :class="sortClass('status') === 'sort-asc' ? 'sort-asc-badge' : 'sort-desc-badge'">{{ sortIndex('status') }}</span>{{ sortIcon('status') }}</span>
|
|
|
</template>
|
|
</template>
|
|
|
</el-table-column>
|
|
</el-table-column>
|
|
|
<el-table-column label="操作" width="180" fixed="right" align="center">
|
|
<el-table-column label="操作" width="180" fixed="right" align="center">
|
|
@@ -369,100 +369,17 @@ export default {
|
|
|
this.sortState = []
|
|
this.sortState = []
|
|
|
this.loadList()
|
|
this.loadList()
|
|
|
},
|
|
},
|
|
|
- sortClass(col) {
|
|
|
|
|
- const s = this.sortState.find(x => x.column === col)
|
|
|
|
|
- if (!s) return ''
|
|
|
|
|
- return s.order === 'asc' ? 'sort-asc' : 'sort-desc'
|
|
|
|
|
- },
|
|
|
|
|
- sortIcon(col) {
|
|
|
|
|
- const s = this.sortState.find(x => x.column === col)
|
|
|
|
|
- if (!s) return ''
|
|
|
|
|
- return s.order === 'asc' ? ' ↑' : ' ↓'
|
|
|
|
|
- },
|
|
|
|
|
- onSortClick(col, event) {
|
|
|
|
|
- if (event.shiftKey) {
|
|
|
|
|
- this.shiftAppendSort(col)
|
|
|
|
|
- } else {
|
|
|
|
|
- this.setPrimarySort(col)
|
|
|
|
|
- }
|
|
|
|
|
- this.loadList()
|
|
|
|
|
- },
|
|
|
|
|
- onSortToggle(col) {
|
|
|
|
|
- const idx = this.sortState.findIndex(s => s.column === col)
|
|
|
|
|
- if (idx >= 0) {
|
|
|
|
|
- this.sortState[idx].order = this.sortState[idx].order === 'asc' ? 'desc' : 'asc'
|
|
|
|
|
- } else {
|
|
|
|
|
- this.sortState = [{ column: col, order: 'asc' }]
|
|
|
|
|
- }
|
|
|
|
|
- this.loadList()
|
|
|
|
|
- },
|
|
|
|
|
- setPrimarySort(col) {
|
|
|
|
|
- const idx = this.sortState.findIndex(s => s.column === col)
|
|
|
|
|
- if (idx >= 0) {
|
|
|
|
|
- const item = this.sortState.splice(idx, 1)[0]
|
|
|
|
|
- this.sortState.unshift(item)
|
|
|
|
|
- } else {
|
|
|
|
|
- this.sortState = [{ column: col, order: 'asc' }]
|
|
|
|
|
- }
|
|
|
|
|
- },
|
|
|
|
|
- shiftAppendSort(col) {
|
|
|
|
|
- const idx = this.sortState.findIndex(s => s.column === col)
|
|
|
|
|
- if (idx >= 0) {
|
|
|
|
|
- this.sortState[idx].order = this.sortState[idx].order === 'asc' ? 'desc' : 'asc'
|
|
|
|
|
- } else if (this.sortState.length < 3) {
|
|
|
|
|
- this.sortState.push({ column: col, order: 'asc' })
|
|
|
|
|
- }
|
|
|
|
|
- },
|
|
|
|
|
- clearSort() {
|
|
|
|
|
- this.sortState = []
|
|
|
|
|
- this.loadList()
|
|
|
|
|
- },
|
|
|
|
|
- sortClass(col) {
|
|
|
|
|
- const s = this.sortState.find(x => x.column === col)
|
|
|
|
|
- if (!s) return ''
|
|
|
|
|
- return s.order === 'asc' ? 'sort-asc' : 'sort-desc'
|
|
|
|
|
- },
|
|
|
|
|
- sortIcon(col) {
|
|
|
|
|
- const s = this.sortState.find(x => x.column === col)
|
|
|
|
|
- if (!s) return ''
|
|
|
|
|
- return s.order === 'asc' ? ' \u2191' : ' \u2193'
|
|
|
|
|
- },
|
|
|
|
|
onSortClick(col, event) {
|
|
onSortClick(col, event) {
|
|
|
- if (event.shiftKey) {
|
|
|
|
|
- this.shiftAppendSort(col)
|
|
|
|
|
- } else {
|
|
|
|
|
- this.setPrimarySort(col)
|
|
|
|
|
- }
|
|
|
|
|
- this.loadList()
|
|
|
|
|
- },
|
|
|
|
|
- onSortToggle(col) {
|
|
|
|
|
const idx = this.sortState.findIndex(s => s.column === col)
|
|
const idx = this.sortState.findIndex(s => s.column === col)
|
|
|
if (idx >= 0) {
|
|
if (idx >= 0) {
|
|
|
- this.sortState[idx].order = this.sortState[idx].order === 'asc' ? 'desc' : 'asc'
|
|
|
|
|
- } else {
|
|
|
|
|
- this.sortState = [{ column: col, order: 'asc' }]
|
|
|
|
|
- }
|
|
|
|
|
- this.loadList()
|
|
|
|
|
- },
|
|
|
|
|
- setPrimarySort(col) {
|
|
|
|
|
- const idx = this.sortState.findIndex(s => s.column === col)
|
|
|
|
|
- if (idx >= 0) {
|
|
|
|
|
- const item = this.sortState.splice(idx, 1)[0]
|
|
|
|
|
- this.sortState.unshift(item)
|
|
|
|
|
|
|
+ if (this.sortState[idx].order === 'asc') {
|
|
|
|
|
+ this.sortState[idx].order = 'desc'
|
|
|
|
|
+ } else {
|
|
|
|
|
+ this.sortState.splice(idx, 1)
|
|
|
|
|
+ }
|
|
|
} else {
|
|
} else {
|
|
|
- this.sortState = [{ column: col, order: 'asc' }]
|
|
|
|
|
- }
|
|
|
|
|
- },
|
|
|
|
|
- shiftAppendSort(col) {
|
|
|
|
|
- const idx = this.sortState.findIndex(s => s.column === col)
|
|
|
|
|
- if (idx >= 0) {
|
|
|
|
|
- this.sortState[idx].order = this.sortState[idx].order === 'asc' ? 'desc' : 'asc'
|
|
|
|
|
- } else if (this.sortState.length < 3) {
|
|
|
|
|
this.sortState.push({ column: col, order: 'asc' })
|
|
this.sortState.push({ column: col, order: 'asc' })
|
|
|
}
|
|
}
|
|
|
- },
|
|
|
|
|
- clearSort() {
|
|
|
|
|
- this.sortState = []
|
|
|
|
|
this.loadList()
|
|
this.loadList()
|
|
|
},
|
|
},
|
|
|
handleSizeChange(val) {
|
|
handleSizeChange(val) {
|