|
@@ -1,22 +1,28 @@
|
|
|
<template>
|
|
|
<div class='app-container'>
|
|
|
- <el-button type="primary" icon="el-icon-plus" size="mini" @click="getDialog">新增</el-button>
|
|
|
+ <el-button type="primary" icon="el-icon-plus" size="mini" @click="getDialog()">新增</el-button>
|
|
|
<!-- 列表 -->
|
|
|
<el-table :data="tableData" v-loading="loading">
|
|
|
<el-table-column label="序号" type="index" align="center" />
|
|
|
- <el-table-column label="分类名称" align="center" />
|
|
|
- <el-table-column label="更新时间" align="center" />
|
|
|
+ <el-table-column label="分类名称" prop="name" align="center" />
|
|
|
+ <el-table-column label="更新时间" align="center">
|
|
|
+ <template slot-scope="scope">
|
|
|
+ {{ parseTime(scope.row.updateTime, '{y}-{m}-{d} {h}:{i}:{s}') }}
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
<el-table-column label="操作" align="center">
|
|
|
<template slot-scope="scope">
|
|
|
- <el-button type="text" @click="getDialog('编辑', scope.row.id)">编辑</el-button>
|
|
|
+ <el-button type="text" @click="getDialog(scope.row.id)">编辑</el-button>
|
|
|
<el-button type="delete" @click="getDelete(scope.row)">删除</el-button>
|
|
|
</template>
|
|
|
</el-table-column>
|
|
|
</el-table>
|
|
|
+ <pagination v-show="total > 0" :total="total" :page.sync="form.pageNum" :limit.sync="form.pageSize"
|
|
|
+ @pagination="getList" />
|
|
|
<!-- 弹窗 -->
|
|
|
<el-dialog :visible.sync="dialogVisible" :title="dialogForm.id ? '编辑' : '新增'" width="500px" :before-close="getClose">
|
|
|
- <el-form label-width="auto">
|
|
|
- <el-form-item label="分类名称:">
|
|
|
+ <el-form label-width="auto" :model="dialogForm" ref="dialogForm">
|
|
|
+ <el-form-item label="分类名称:" prop="name" :rules="[{ required: true, message: '请输入分类名称', trigger: 'blur' }]">
|
|
|
<el-input v-model="dialogForm.name" placeholder="请输入分类名称" />
|
|
|
</el-form-item>
|
|
|
</el-form>
|
|
@@ -29,6 +35,7 @@
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
+import { list, detail, submit, change } from '@/api/music/blogclass'
|
|
|
export default {
|
|
|
data() {
|
|
|
return {
|
|
@@ -50,17 +57,31 @@ export default {
|
|
|
}
|
|
|
},
|
|
|
mounted() {
|
|
|
-
|
|
|
+ this.getList()
|
|
|
},
|
|
|
methods: {
|
|
|
// 列表
|
|
|
getList() {
|
|
|
-
|
|
|
+ this.loading = true
|
|
|
+ list(this.form).then(res => {
|
|
|
+ if (res.code === 0) {
|
|
|
+ this.tableData = res.data.records
|
|
|
+ this.total = res.data.total
|
|
|
+ this.loading = false
|
|
|
+ }
|
|
|
+ })
|
|
|
},
|
|
|
|
|
|
// 弹窗
|
|
|
getDialog(id) {
|
|
|
this.dialogVisible = true
|
|
|
+ if (id) {
|
|
|
+ detail(id).then(res => {
|
|
|
+ if (res.code === 0) {
|
|
|
+ this.dialogForm = res.data
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
},
|
|
|
|
|
|
// 取消
|
|
@@ -71,7 +92,33 @@ export default {
|
|
|
|
|
|
// 确定
|
|
|
getSubmit() {
|
|
|
+ this.$refs.dialogForm.validate((valid) => {
|
|
|
+ if (valid) {
|
|
|
+ submit(this.dialogForm).then(res => {
|
|
|
+ if (res.code === 0) {
|
|
|
+ this.$message.success('提交成功!')
|
|
|
+ this.getClose()
|
|
|
+ this.getList()
|
|
|
+ }
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ return false
|
|
|
+ }
|
|
|
+ })
|
|
|
+ },
|
|
|
|
|
|
+ // 删除
|
|
|
+ getDelete(row) {
|
|
|
+ this.$confirm(`是否删除${row.name}?`, '提示', {
|
|
|
+ type: 'warning'
|
|
|
+ }).then(() => {
|
|
|
+ change(row.id, 2).then(res => {
|
|
|
+ if (res.code === 0) {
|
|
|
+ this.$message.success('删除成功!')
|
|
|
+ this.getList()
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }).catch(() => { })
|
|
|
}
|
|
|
}
|
|
|
}
|