perf:refine complexTable demo
This commit is contained in:
parent
72f653dcc7
commit
38192b828d
|
@ -23,3 +23,18 @@ export function fetchPv(pv) {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function createArticle(data) {
|
||||||
|
return request({
|
||||||
|
url: '/article/create',
|
||||||
|
method: 'post',
|
||||||
|
data
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
export function updateArticle(data) {
|
||||||
|
return request({
|
||||||
|
url: '/article/update',
|
||||||
|
method: 'post',
|
||||||
|
data
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
|
@ -60,5 +60,11 @@ export default {
|
||||||
status: 'published',
|
status: 'published',
|
||||||
tags: [],
|
tags: [],
|
||||||
title: 'vue-element-admin'
|
title: 'vue-element-admin'
|
||||||
|
}),
|
||||||
|
createArticle: () => ({
|
||||||
|
data: 'success'
|
||||||
|
}),
|
||||||
|
updateArticle: () => ({
|
||||||
|
data: 'success'
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,6 +17,8 @@ Mock.mock(/\/user\/info\.*/, 'get', loginAPI.getUserInfo)
|
||||||
Mock.mock(/\/article\/list/, 'get', articleAPI.getList)
|
Mock.mock(/\/article\/list/, 'get', articleAPI.getList)
|
||||||
Mock.mock(/\/article\/detail/, 'get', articleAPI.getArticle)
|
Mock.mock(/\/article\/detail/, 'get', articleAPI.getArticle)
|
||||||
Mock.mock(/\/article\/pv/, 'get', articleAPI.getPv)
|
Mock.mock(/\/article\/pv/, 'get', articleAPI.getPv)
|
||||||
|
Mock.mock(/\/article\/create/, 'post', articleAPI.createArticle)
|
||||||
|
Mock.mock(/\/article\/update/, 'post', articleAPI.updateArticle)
|
||||||
|
|
||||||
// 搜索相关
|
// 搜索相关
|
||||||
Mock.mock(/\/search\/user/, 'get', remoteSearchAPI.searchUser)
|
Mock.mock(/\/search\/user/, 'get', remoteSearchAPI.searchUser)
|
||||||
|
|
|
@ -3,90 +3,79 @@
|
||||||
<div class="filter-container">
|
<div class="filter-container">
|
||||||
<el-input @keyup.enter.native="handleFilter" style="width: 200px;" class="filter-item" placeholder="标题" v-model="listQuery.title">
|
<el-input @keyup.enter.native="handleFilter" style="width: 200px;" class="filter-item" placeholder="标题" v-model="listQuery.title">
|
||||||
</el-input>
|
</el-input>
|
||||||
|
|
||||||
<el-select clearable style="width: 90px" class="filter-item" v-model="listQuery.importance" placeholder="重要性">
|
<el-select clearable style="width: 90px" class="filter-item" v-model="listQuery.importance" placeholder="重要性">
|
||||||
<el-option v-for="item in importanceOptions" :key="item" :label="item" :value="item">
|
<el-option v-for="item in importanceOptions" :key="item" :label="item" :value="item">
|
||||||
</el-option>
|
</el-option>
|
||||||
</el-select>
|
</el-select>
|
||||||
|
|
||||||
<el-select clearable class="filter-item" style="width: 130px" v-model="listQuery.type" placeholder="类型">
|
<el-select clearable class="filter-item" style="width: 130px" v-model="listQuery.type" placeholder="类型">
|
||||||
<el-option v-for="item in calendarTypeOptions" :key="item.key" :label="item.display_name+'('+item.key+')'" :value="item.key">
|
<el-option v-for="item in calendarTypeOptions" :key="item.key" :label="item.display_name+'('+item.key+')'" :value="item.key">
|
||||||
</el-option>
|
</el-option>
|
||||||
</el-select>
|
</el-select>
|
||||||
|
|
||||||
<el-select @change='handleFilter' style="width: 120px" class="filter-item" v-model="listQuery.sort" placeholder="排序">
|
<el-select @change='handleFilter' style="width: 120px" class="filter-item" v-model="listQuery.sort" placeholder="排序">
|
||||||
<el-option v-for="item in sortOptions" :key="item.key" :label="item.label" :value="item.key">
|
<el-option v-for="item in sortOptions" :key="item.key" :label="item.label" :value="item.key">
|
||||||
</el-option>
|
</el-option>
|
||||||
</el-select>
|
</el-select>
|
||||||
|
|
||||||
<el-button class="filter-item" type="primary" v-waves icon="el-icon-search" @click="handleFilter">搜索</el-button>
|
<el-button class="filter-item" type="primary" v-waves icon="el-icon-search" @click="handleFilter">搜索</el-button>
|
||||||
<el-button class="filter-item" style="margin-left: 10px;" @click="handleCreate" type="primary" icon="el-icon-edit">添加</el-button>
|
<el-button class="filter-item" style="margin-left: 10px;" @click="handleCreate" type="primary" icon="el-icon-edit">添加</el-button>
|
||||||
<el-button class="filter-item" type="primary" icon="el-icon-download" @click="handleDownload">导出</el-button>
|
<el-button class="filter-item" type="primary" v-waves icon="el-icon-download" @click="handleDownload">导出</el-button>
|
||||||
<el-checkbox class="filter-item" style='margin-left:15px;' @change='tableKey=tableKey+1' v-model="showAuditor">显示审核人</el-checkbox>
|
<el-checkbox class="filter-item" style='margin-left:15px;' @change='tableKey=tableKey+1' v-model="showAuditor">显示审核人</el-checkbox>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<el-table :key='tableKey' :data="list" v-loading="listLoading" element-loading-text="给我一点时间" border fit highlight-current-row style="width: 100%">
|
<el-table :key='tableKey' :data="list" v-loading="listLoading" element-loading-text="给我一点时间" border fit highlight-current-row
|
||||||
|
style="width: 100%">
|
||||||
<el-table-column align="center" label="序号" width="65">
|
<el-table-column align="center" label="序号" width="65">
|
||||||
<template slot-scope="scope">
|
<template slot-scope="scope">
|
||||||
<span>{{scope.row.id}}</span>
|
<span>{{scope.row.id}}</span>
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
|
|
||||||
<el-table-column width="180px" align="center" label="时间">
|
<el-table-column width="180px" align="center" label="时间">
|
||||||
<template slot-scope="scope">
|
<template slot-scope="scope">
|
||||||
<span>{{scope.row.timestamp | parseTime('{y}-{m}-{d} {h}:{i}')}}</span>
|
<span>{{scope.row.timestamp | parseTime('{y}-{m}-{d} {h}:{i}')}}</span>
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
|
|
||||||
<el-table-column min-width="150px" label="标题">
|
<el-table-column min-width="150px" label="标题">
|
||||||
<template slot-scope="scope">
|
<template slot-scope="scope">
|
||||||
<span class="link-type" @click="handleUpdate(scope.row)">{{scope.row.title}}</span>
|
<span class="link-type" @click="handleUpdate(scope.row)">{{scope.row.title}}</span>
|
||||||
<el-tag>{{scope.row.type | typeFilter}}</el-tag>
|
<el-tag>{{scope.row.type | typeFilter}}</el-tag>
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
|
|
||||||
<el-table-column width="110px" align="center" label="作者">
|
<el-table-column width="110px" align="center" label="作者">
|
||||||
<template slot-scope="scope">
|
<template slot-scope="scope">
|
||||||
<span>{{scope.row.author}}</span>
|
<span>{{scope.row.author}}</span>
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
|
|
||||||
<el-table-column width="110px" v-if='showAuditor' align="center" label="审核人">
|
<el-table-column width="110px" v-if='showAuditor' align="center" label="审核人">
|
||||||
<template slot-scope="scope">
|
<template slot-scope="scope">
|
||||||
<span style='color:red;'>{{scope.row.auditor}}</span>
|
<span style='color:red;'>{{scope.row.auditor}}</span>
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
|
|
||||||
<el-table-column width="80px" label="重要性">
|
<el-table-column width="80px" label="重要性">
|
||||||
<template slot-scope="scope">
|
<template slot-scope="scope">
|
||||||
<svg-icon v-for="n in +scope.row.importance" icon-class="star" class="meta-item__icon" :key="n"></svg-icon>
|
<svg-icon v-for="n in +scope.row.importance" icon-class="star" class="meta-item__icon" :key="n"></svg-icon>
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
|
|
||||||
<el-table-column align="center" label="阅读数" width="95">
|
<el-table-column align="center" label="阅读数" width="95">
|
||||||
<template slot-scope="scope">
|
<template slot-scope="scope">
|
||||||
<span class="link-type" @click='handleFetchPv(scope.row.pageviews)'>{{scope.row.pageviews}}</span>
|
<span v-if="scope.row.pageviews" class="link-type" @click='handleFetchPv(scope.row.pageviews)'>{{scope.row.pageviews}}</span>
|
||||||
|
<span v-else>无</span>
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
|
|
||||||
<el-table-column class-name="status-col" label="状态" width="100">
|
<el-table-column class-name="status-col" label="状态" width="100">
|
||||||
<template slot-scope="scope">
|
<template slot-scope="scope">
|
||||||
<el-tag :type="scope.row.status | statusFilter">{{scope.row.status}}</el-tag>
|
<el-tag :type="scope.row.status | statusFilter">{{scope.row.status}}</el-tag>
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
|
<el-table-column align="center" label="操作" width="220" class-name="small-padding">
|
||||||
<el-table-column align="center" label="操作" width="150">
|
|
||||||
<template slot-scope="scope">
|
<template slot-scope="scope">
|
||||||
<el-button v-if="scope.row.status!='published'" size="small" type="success" @click="handleModifyStatus(scope.row,'published')">发布
|
<el-button type="primary" size="mini" @click="handleUpdate(scope.row)">编辑</el-button>
|
||||||
|
<el-button v-if="scope.row.status!='published'" size="mini" type="success" @click="handleModifyStatus(scope.row,'published')">发布
|
||||||
</el-button>
|
</el-button>
|
||||||
<el-button v-if="scope.row.status!='draft'" size="small" @click="handleModifyStatus(scope.row,'draft')">草稿
|
<el-button v-if="scope.row.status!='draft'" size="mini" @click="handleModifyStatus(scope.row,'draft')">草稿
|
||||||
</el-button>
|
</el-button>
|
||||||
<el-button v-if="scope.row.status!='deleted'" size="small" type="danger" @click="handleModifyStatus(scope.row,'deleted')">删除
|
<el-button v-if="scope.row.status!='deleted'" size="mini" type="danger" @click="handleModifyStatus(scope.row,'deleted')">删除
|
||||||
</el-button>
|
</el-button>
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
|
|
||||||
</el-table>
|
</el-table>
|
||||||
|
|
||||||
<div v-show="!listLoading" class="pagination-container">
|
<div v-show="!listLoading" class="pagination-container">
|
||||||
|
@ -96,34 +85,29 @@
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<el-dialog :title="textMap[dialogStatus]" :visible.sync="dialogFormVisible">
|
<el-dialog :title="textMap[dialogStatus]" :visible.sync="dialogFormVisible">
|
||||||
<el-form class="small-space" :model="temp" label-position="left" label-width="70px" style='width: 400px; margin-left:50px;'>
|
<el-form :rules="rules" ref="dataForm" :model="temp" label-position="left" label-width="70px" style='width: 400px; margin-left:50px;'>
|
||||||
<el-form-item label="类型">
|
<el-form-item label="类型" prop="type">
|
||||||
<el-select class="filter-item" v-model="temp.type" placeholder="请选择">
|
<el-select class="filter-item" v-model="temp.type" placeholder="请选择">
|
||||||
<el-option v-for="item in calendarTypeOptions" :key="item.key" :label="item.display_name" :value="item.key">
|
<el-option v-for="item in calendarTypeOptions" :key="item.key" :label="item.display_name" :value="item.key">
|
||||||
</el-option>
|
</el-option>
|
||||||
</el-select>
|
</el-select>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
|
<el-form-item label="时间" prop="timestamp">
|
||||||
|
<el-date-picker v-model="temp.timestamp" type="datetime" placeholder="选择日期时间">
|
||||||
|
</el-date-picker>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="标题" prop="title">
|
||||||
|
<el-input v-model="temp.title"></el-input>
|
||||||
|
</el-form-item>
|
||||||
<el-form-item label="状态">
|
<el-form-item label="状态">
|
||||||
<el-select class="filter-item" v-model="temp.status" placeholder="请选择">
|
<el-select class="filter-item" v-model="temp.status" placeholder="请选择">
|
||||||
<el-option v-for="item in statusOptions" :key="item" :label="item" :value="item">
|
<el-option v-for="item in statusOptions" :key="item" :label="item" :value="item">
|
||||||
</el-option>
|
</el-option>
|
||||||
</el-select>
|
</el-select>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
|
|
||||||
<el-form-item label="时间">
|
|
||||||
<el-date-picker v-model="temp.timestamp" type="datetime" placeholder="选择日期时间">
|
|
||||||
</el-date-picker>
|
|
||||||
</el-form-item>
|
|
||||||
|
|
||||||
<el-form-item label="标题">
|
|
||||||
<el-input v-model="temp.title"></el-input>
|
|
||||||
</el-form-item>
|
|
||||||
|
|
||||||
<el-form-item label="重要性">
|
<el-form-item label="重要性">
|
||||||
<el-rate style="margin-top:8px;" v-model="temp.importance" :colors="['#99A9BF', '#F7BA2A', '#FF9900']" :max='3'></el-rate>
|
<el-rate style="margin-top:8px;" v-model="temp.importance" :colors="['#99A9BF', '#F7BA2A', '#FF9900']" :max='3'></el-rate>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
|
|
||||||
<el-form-item label="点评">
|
<el-form-item label="点评">
|
||||||
<el-input type="textarea" :autosize="{ minRows: 2, maxRows: 4}" placeholder="请输入内容" v-model="temp.remark">
|
<el-input type="textarea" :autosize="{ minRows: 2, maxRows: 4}" placeholder="请输入内容" v-model="temp.remark">
|
||||||
</el-input>
|
</el-input>
|
||||||
|
@ -131,8 +115,8 @@
|
||||||
</el-form>
|
</el-form>
|
||||||
<div slot="footer" class="dialog-footer">
|
<div slot="footer" class="dialog-footer">
|
||||||
<el-button @click="dialogFormVisible = false">取 消</el-button>
|
<el-button @click="dialogFormVisible = false">取 消</el-button>
|
||||||
<el-button v-if="dialogStatus=='create'" type="primary" @click="create">确 定</el-button>
|
<el-button v-if="dialogStatus=='create'" type="primary" @click="createData">确 定</el-button>
|
||||||
<el-button v-else type="primary" @click="update">确 定</el-button>
|
<el-button v-else type="primary" @click="updateData">确 定</el-button>
|
||||||
</div>
|
</div>
|
||||||
</el-dialog>
|
</el-dialog>
|
||||||
|
|
||||||
|
@ -150,8 +134,8 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { fetchList, fetchPv } from '@/api/article'
|
import { fetchList, fetchPv, createArticle, updateArticle } from '@/api/article'
|
||||||
import waves from '@/directive/waves/index.js' // 水波纹指令
|
import waves from '@/directive/waves' // 水波纹指令
|
||||||
import { parseTime } from '@/utils'
|
import { parseTime } from '@/utils'
|
||||||
|
|
||||||
const calendarTypeOptions = [
|
const calendarTypeOptions = [
|
||||||
|
@ -161,7 +145,7 @@ const calendarTypeOptions = [
|
||||||
{ key: 'EU', display_name: '欧元区' }
|
{ key: 'EU', display_name: '欧元区' }
|
||||||
]
|
]
|
||||||
|
|
||||||
// arr to obj
|
// arr to obj ,such as { CN : "中国", US : "美国" }
|
||||||
const calendarTypeKeyValue = calendarTypeOptions.reduce((acc, cur) => {
|
const calendarTypeKeyValue = calendarTypeOptions.reduce((acc, cur) => {
|
||||||
acc[cur.key] = cur.display_name
|
acc[cur.key] = cur.display_name
|
||||||
return acc
|
return acc
|
||||||
|
@ -174,6 +158,7 @@ export default {
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
|
tableKey: 0,
|
||||||
list: null,
|
list: null,
|
||||||
total: null,
|
total: null,
|
||||||
listLoading: true,
|
listLoading: true,
|
||||||
|
@ -185,19 +170,20 @@ export default {
|
||||||
type: undefined,
|
type: undefined,
|
||||||
sort: '+id'
|
sort: '+id'
|
||||||
},
|
},
|
||||||
temp: {
|
|
||||||
id: undefined,
|
|
||||||
importance: 0,
|
|
||||||
remark: '',
|
|
||||||
timestamp: 0,
|
|
||||||
title: '',
|
|
||||||
type: '',
|
|
||||||
status: 'published'
|
|
||||||
},
|
|
||||||
importanceOptions: [1, 2, 3],
|
importanceOptions: [1, 2, 3],
|
||||||
calendarTypeOptions,
|
calendarTypeOptions,
|
||||||
sortOptions: [{ label: '按ID升序列', key: '+id' }, { label: '按ID降序', key: '-id' }],
|
sortOptions: [{ label: '按ID升序列', key: '+id' }, { label: '按ID降序', key: '-id' }],
|
||||||
statusOptions: ['published', 'draft', 'deleted'],
|
statusOptions: ['published', 'draft', 'deleted'],
|
||||||
|
showAuditor: false,
|
||||||
|
temp: {
|
||||||
|
id: undefined,
|
||||||
|
importance: 1,
|
||||||
|
remark: '',
|
||||||
|
timestamp: new Date(),
|
||||||
|
title: '',
|
||||||
|
type: '',
|
||||||
|
status: 'published'
|
||||||
|
},
|
||||||
dialogFormVisible: false,
|
dialogFormVisible: false,
|
||||||
dialogStatus: '',
|
dialogStatus: '',
|
||||||
textMap: {
|
textMap: {
|
||||||
|
@ -206,8 +192,11 @@ export default {
|
||||||
},
|
},
|
||||||
dialogPvVisible: false,
|
dialogPvVisible: false,
|
||||||
pvData: [],
|
pvData: [],
|
||||||
showAuditor: false,
|
rules: {
|
||||||
tableKey: 0
|
type: [{ required: true, message: 'type is required', trigger: 'change' }],
|
||||||
|
timestamp: [{ type: 'date', required: true, message: 'timestamp is required', trigger: 'change' }],
|
||||||
|
title: [{ required: true, message: 'title is required', trigger: 'blur' }]
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
filters: {
|
filters: {
|
||||||
|
@ -247,15 +236,6 @@ export default {
|
||||||
this.listQuery.page = val
|
this.listQuery.page = val
|
||||||
this.getList()
|
this.getList()
|
||||||
},
|
},
|
||||||
timeFilter(time) {
|
|
||||||
if (!time[0]) {
|
|
||||||
this.listQuery.start = undefined
|
|
||||||
this.listQuery.end = undefined
|
|
||||||
return
|
|
||||||
}
|
|
||||||
this.listQuery.start = parseInt(+time[0] / 1000)
|
|
||||||
this.listQuery.end = parseInt((+time[1] + 3600 * 1000 * 24) / 1000)
|
|
||||||
},
|
|
||||||
handleModifyStatus(row, status) {
|
handleModifyStatus(row, status) {
|
||||||
this.$message({
|
this.$message({
|
||||||
message: '操作成功',
|
message: '操作成功',
|
||||||
|
@ -263,30 +243,31 @@ export default {
|
||||||
})
|
})
|
||||||
row.status = status
|
row.status = status
|
||||||
},
|
},
|
||||||
|
resetTemp() {
|
||||||
|
this.temp = {
|
||||||
|
id: undefined,
|
||||||
|
importance: 1,
|
||||||
|
remark: '',
|
||||||
|
timestamp: new Date(),
|
||||||
|
title: '',
|
||||||
|
status: 'published',
|
||||||
|
type: ''
|
||||||
|
}
|
||||||
|
},
|
||||||
handleCreate() {
|
handleCreate() {
|
||||||
this.resetTemp()
|
this.resetTemp()
|
||||||
this.dialogStatus = 'create'
|
this.dialogStatus = 'create'
|
||||||
this.dialogFormVisible = true
|
this.dialogFormVisible = true
|
||||||
},
|
this.$nextTick(() => {
|
||||||
handleUpdate(row) {
|
this.$refs['dataForm'].clearValidate()
|
||||||
this.temp = Object.assign({}, row)
|
|
||||||
this.dialogStatus = 'update'
|
|
||||||
this.dialogFormVisible = true
|
|
||||||
},
|
|
||||||
handleDelete(row) {
|
|
||||||
this.$notify({
|
|
||||||
title: '成功',
|
|
||||||
message: '删除成功',
|
|
||||||
type: 'success',
|
|
||||||
duration: 2000
|
|
||||||
})
|
})
|
||||||
const index = this.list.indexOf(row)
|
|
||||||
this.list.splice(index, 1)
|
|
||||||
},
|
},
|
||||||
create() {
|
createData() {
|
||||||
this.temp.id = parseInt(Math.random() * 100) + 1024
|
this.$refs['dataForm'].validate((valid) => {
|
||||||
this.temp.timestamp = +new Date()
|
if (valid) {
|
||||||
|
this.temp.id = parseInt(Math.random() * 100) + 1024 // mock a id
|
||||||
this.temp.author = '原创作者'
|
this.temp.author = '原创作者'
|
||||||
|
createArticle(this.temp).then(() => {
|
||||||
this.list.unshift(this.temp)
|
this.list.unshift(this.temp)
|
||||||
this.dialogFormVisible = false
|
this.dialogFormVisible = false
|
||||||
this.$notify({
|
this.$notify({
|
||||||
|
@ -295,9 +276,25 @@ export default {
|
||||||
type: 'success',
|
type: 'success',
|
||||||
duration: 2000
|
duration: 2000
|
||||||
})
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
|
})
|
||||||
},
|
},
|
||||||
update() {
|
handleUpdate(row) {
|
||||||
this.temp.timestamp = +this.temp.timestamp
|
this.temp = Object.assign({}, row) // copy obj
|
||||||
|
this.temp.timestamp = new Date(this.temp.timestamp)
|
||||||
|
this.dialogStatus = 'update'
|
||||||
|
this.dialogFormVisible = true
|
||||||
|
this.$nextTick(() => {
|
||||||
|
this.$refs['dataForm'].clearValidate()
|
||||||
|
})
|
||||||
|
},
|
||||||
|
updateData() {
|
||||||
|
this.$refs['dataForm'].validate((valid) => {
|
||||||
|
if (valid) {
|
||||||
|
const tempData = Object.assign({}, this.temp)
|
||||||
|
tempData.timestamp = +new Date(tempData.timestamp) // change Thu Nov 30 2017 16:41:05 GMT+0800 (CST) to 1512031311464
|
||||||
|
updateArticle(tempData).then(() => {
|
||||||
for (const v of this.list) {
|
for (const v of this.list) {
|
||||||
if (v.id === this.temp.id) {
|
if (v.id === this.temp.id) {
|
||||||
const index = this.list.indexOf(v)
|
const index = this.list.indexOf(v)
|
||||||
|
@ -312,17 +309,19 @@ export default {
|
||||||
type: 'success',
|
type: 'success',
|
||||||
duration: 2000
|
duration: 2000
|
||||||
})
|
})
|
||||||
},
|
})
|
||||||
resetTemp() {
|
|
||||||
this.temp = {
|
|
||||||
id: undefined,
|
|
||||||
importance: 0,
|
|
||||||
remark: '',
|
|
||||||
timestamp: 0,
|
|
||||||
title: '',
|
|
||||||
status: 'published',
|
|
||||||
type: ''
|
|
||||||
}
|
}
|
||||||
|
})
|
||||||
|
},
|
||||||
|
handleDelete(row) {
|
||||||
|
this.$notify({
|
||||||
|
title: '成功',
|
||||||
|
message: '删除成功',
|
||||||
|
type: 'success',
|
||||||
|
duration: 2000
|
||||||
|
})
|
||||||
|
const index = this.list.indexOf(row)
|
||||||
|
this.list.splice(index, 1)
|
||||||
},
|
},
|
||||||
handleFetchPv(pv) {
|
handleFetchPv(pv) {
|
||||||
fetchPv(pv).then(response => {
|
fetchPv(pv).then(response => {
|
||||||
|
|
Loading…
Reference in New Issue