|
@@ -0,0 +1,145 @@
|
|
|
|
+<template>
|
|
|
|
+ <div class="app-container">
|
|
|
|
+ <div class="filter-container">
|
|
|
|
+ <el-button class="filter-item" type="primary" icon="el-icon-edit" @click="handleCreate">
|
|
|
|
+ 添加一级菜单
|
|
|
|
+ </el-button>
|
|
|
|
+ <el-button class="filter-item" type="primary" icon="el-icon-upload2" @click="handlePush">
|
|
|
|
+ 发布公众号菜单
|
|
|
|
+ </el-button>
|
|
|
|
+ </div>
|
|
|
|
+ <el-table v-loading="listLoading" row-key="id" :data="list" default-expand-all :row-class-name="rowClassName" border fit highlight-current-row style="width:100%">
|
|
|
|
+ <el-table-column label="菜单名称" prop="name" align="center" />
|
|
|
|
+ <el-table-column label="按钮类型" prop="type" align="center" />
|
|
|
|
+ <el-table-column label="排序" prop="name" width="80" align="center">
|
|
|
|
+ <template slot-scope="{row}">
|
|
|
|
+ <el-input v-model="row.sort" maxlength="4" minlength="1" @blur="handleOnInputBlur(row)" />
|
|
|
|
+ </template>
|
|
|
|
+ </el-table-column>
|
|
|
|
+ <el-table-column label="设置" width="250" align="center">
|
|
|
|
+ <template slot-scope="{row}">
|
|
|
|
+ <el-button plain size="mini" :disabled="row.parentId | disableAddSub" @click="handleCreateNextLevel(row)">添加子菜单
|
|
|
|
+ </el-button>
|
|
|
|
+ </template>
|
|
|
|
+ </el-table-column>
|
|
|
|
+ <el-table-column label="操作" width="150" align="center">
|
|
|
|
+ <template slot-scope="{row}">
|
|
|
|
+ <el-button size="mini" type="primary" @click="handleUpdate(row)">编辑
|
|
|
|
+ </el-button>
|
|
|
|
+ <el-button size="mini" type="danger" @click="handleDelete(row)">删除
|
|
|
|
+ </el-button>
|
|
|
|
+ </template>
|
|
|
|
+ </el-table-column>
|
|
|
|
+ </el-table>
|
|
|
|
+ </div>
|
|
|
|
+</template>
|
|
|
|
+
|
|
|
|
+<script>
|
|
|
|
+import { fetchList, deleteMenu, updateMenu, pushWechatMenu } from '@/api/wechat/menu'
|
|
|
|
+
|
|
|
|
+export default {
|
|
|
|
+ name: 'WeChatMenuList',
|
|
|
|
+ filters: {
|
|
|
|
+ disableAddSub(value) {
|
|
|
|
+ if (value !== 1 && value !== 2) {
|
|
|
|
+ return true
|
|
|
|
+ } else {
|
|
|
|
+ return false
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+ data() {
|
|
|
|
+ return {
|
|
|
|
+ list: [],
|
|
|
|
+ listQuery: {
|
|
|
|
+ // type 类型: 1采美,2呵呵商城
|
|
|
|
+ type: '1'
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+ watch: {
|
|
|
|
+ $route(route) {
|
|
|
|
+ this.getList()
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+ created() {
|
|
|
|
+ this.getList()
|
|
|
|
+ },
|
|
|
|
+ methods: {
|
|
|
|
+ rowClassName: function(scope) {
|
|
|
|
+ if (scope.row.parentId === 1 || scope.row.parentId === 2) {
|
|
|
|
+ return 'parent-row'
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+ getList() {
|
|
|
|
+ this.listLoading = true
|
|
|
|
+ fetchList(this.listQuery).then(response => {
|
|
|
|
+ this.listLoading = false
|
|
|
|
+ this.list = response.data
|
|
|
|
+ // Just to simulate the time of the request
|
|
|
|
+ setTimeout(() => {
|
|
|
|
+ this.listLoading = false
|
|
|
|
+ }, 1.5 * 1000)
|
|
|
|
+ })
|
|
|
|
+ },
|
|
|
|
+ handleCreate() {
|
|
|
|
+ this.$router.push({ path: '/wechat/caimei/menus/add', query: { parentId: this.listQuery.type, title: '采美公众号' }})
|
|
|
|
+ },
|
|
|
|
+ handleUpdate(row) {
|
|
|
|
+ this.$router.push({ path: '/wechat/caimei/menus/edit', query: { id: row.id, parentId: row.parentId, title: row.parentName }})
|
|
|
|
+ },
|
|
|
|
+ handleCreateNextLevel(row) {
|
|
|
|
+ this.$router.push({ path: '/wechat/caimei/menus/add', query: { parentId: row.id, title: row.name }})
|
|
|
|
+ },
|
|
|
|
+ handleDelete(row) {
|
|
|
|
+ this.$confirm('是否要删除该菜单', '提示', {
|
|
|
|
+ confirmButtonText: '确定',
|
|
|
|
+ cancelButtonText: '取消',
|
|
|
|
+ type: 'warning'
|
|
|
|
+ }).then(() => {
|
|
|
|
+ deleteMenu(row.id).then(response => {
|
|
|
|
+ this.$message({
|
|
|
|
+ message: '删除成功',
|
|
|
|
+ type: 'success',
|
|
|
|
+ duration: 1000
|
|
|
|
+ })
|
|
|
|
+ this.getList()
|
|
|
|
+ })
|
|
|
|
+ })
|
|
|
|
+ },
|
|
|
|
+ handlePush() {
|
|
|
|
+ this.$confirm('是否要发布菜单', '提示', {
|
|
|
|
+ confirmButtonText: '确定',
|
|
|
|
+ cancelButtonText: '取消',
|
|
|
|
+ type: 'warning'
|
|
|
|
+ }).then(() => {
|
|
|
|
+ pushWechatMenu(this.listQuery.type).then(response => {
|
|
|
|
+ this.$message({
|
|
|
|
+ message: '删除成功',
|
|
|
|
+ type: 'success',
|
|
|
|
+ duration: 1000
|
|
|
|
+ })
|
|
|
|
+ this.getList()
|
|
|
|
+ })
|
|
|
|
+ })
|
|
|
|
+ },
|
|
|
|
+ handleOnInputBlur(row) {
|
|
|
|
+ // 更新排序
|
|
|
|
+ updateMenu(row.id, { sort: row.sort }).then(response => {
|
|
|
|
+ this.$message({
|
|
|
|
+ message: '操作成功',
|
|
|
|
+ type: 'success',
|
|
|
|
+ duration: 1000
|
|
|
|
+ })
|
|
|
|
+ this.getList()
|
|
|
|
+ })
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+</script>
|
|
|
|
+
|
|
|
|
+<style>
|
|
|
|
+.el-table .parent-row {
|
|
|
|
+ background-color: #fdf6ec;
|
|
|
|
+}
|
|
|
|
+</style>
|