1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071 |
- <template>
- <div class="app-container" style="overflow: auto">
- <el-row :gutter="10" class="mb8 mtt"><el-button type="primary" icon="el-icon-plus" @click="op('add', {})">新增</el-button></el-row>
- <el-table :data="response" row-key="id" :default-expand-all="false" :tree-props="{ children: 'children', hasChildren: 'hasChildren' }">
- <el-table-column prop="title" label="名称" width="260"></el-table-column>
- <el-table-column prop="orderNum" label="排序" align="center" width="200"></el-table-column>
- <el-table-column label="状态" align="center" prop="state" width="170">
- <template slot-scope="scope">
- <el-tag type="success" v-if="scope.row.state == 0">正常</el-tag>
- <el-tag type="danger" v-if="scope.row.state == 1">停用</el-tag>
- </template>
- </el-table-column>
- <el-table-column label="操作" align="center">
- <template slot-scope="scope">
- <el-button size="mini" type="text" icon="el-icon-edit" @click="op('edit', scope.row)" v-hasPermi="['work:column:edit']">修改</el-button>
- <el-button size="mini" type="text" icon="el-icon-plus" @click="op('add', scope.row)" v-if="scope.row.ancestors.length < 2">新增</el-button>
- <el-button v-if="scope.row.parentId != 0" size="mini" type="text" icon="el-icon-delete" @click="del(scope.row)">删除</el-button>
- </template>
- </el-table-column>
- <template slot="empty">
- <el-empty></el-empty>
- </template>
- </el-table>
- </div>
- </template>
- <script>
- import edit from './edit';
- export default {
- name: 'Column',
- data() {
- return {
- response: [{ ancestors: [] }],
- queryParams: {}
- };
- },
- created() {
- this.getList();
- },
- methods: {
- getList() {
- this.get({ url: '/work/column/tree', data: this.queryParams }).then(response => {
- response.data.forEach(item => {
- if (item.ancestors) {
- item.ancestors = item.ancestors.split(',');
- } else {
- item.ancestors = [];
- }
- });
- this.response = this.handleTree(response.data, 'id');
- });
- },
- op(tag, row) {
- if (tag == 'add') {
- this.iframe({ obj: edit, param: { parentId: row.id, parentName: row.title }, title: '新增栏目', width: '550px', height: '400px' });
- }
- if (tag == 'edit') {
- this.iframe({ obj: edit, param: { id: row.id }, title: '编辑栏目', width: '50%', height: '60%' });
- }
- },
- del(row) {
- this.$confirm('是否确认删除选中数据?,会和下级数据一起删除', '警告', { type: 'warning' }).then(() => {
- this.get({ url: '/work/column/remove/' + row.id }).then(response => {
- this.$modal.msgSuccess('删除成功');
- this.getList();
- });
- });
- }
- }
- };
- </script>
|