MrShi
2025-04-11 3a45da15c947c2d478a44a51bd0f926647b1b841
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
<template>
  <TableLayout :permissions="['system:permission:query']">
    <!-- 搜索表单 -->
    <el-form ref="searchForm" slot="search-form" :model="searchForm" label-width="100px" inline>
      <el-form-item label="权限编码" prop="code">
        <el-input v-model="searchForm.code" v-trim placeholder="请输入权限编码" @keypress.enter.native="refresh"/>
      </el-form-item>
      <el-form-item label="权限名称" prop="name">
        <el-input v-model="searchForm.name" v-trim placeholder="请输入权限名称" @keypress.enter.native="refresh"/>
      </el-form-item>
      <el-form-item label="平台类型" prop="type">
        <el-select v-model="type" placeholder="请选择" @change="refresh" clearable>
          <el-option label="平台端" value="1"></el-option>
          <el-option label="商户端" value="2"></el-option>
          <el-option label="企业端" value="3"></el-option>
        </el-select>
      </el-form-item>
 
      <section>
        <el-button type="primary" @click="search">搜索</el-button>
        <el-button @click="reset">重置</el-button>
      </section>
    </el-form>
    <!-- 表格和分页 -->
    <template v-slot:table-wrap>
      <ul class="toolbar" v-permissions="['system:permission:create', 'system:permission:delete']">
        <li><el-button type="primary" @click="$refs.operaPermissionWindow.open('新建系统权限')" icon="el-icon-plus" v-permissions="['system:permission:create']">新建</el-button></li>
        <li><el-button @click="deleteByIdInBatch" icon="el-icon-delete" v-permissions="['system:permission:delete']">删除</el-button></li>
 
     </ul>
      <el-table
        v-loading="isWorking.search"
        :data="tableData.list"
        :default-sort = "{prop: 'createTime', order: 'descending'}"
        stripe
        @selection-change="handleSelectionChange"
        @sort-change="handleSortChange"
      >
        <el-table-column type="selection" fixed="left" width="55"></el-table-column>
        <el-table-column prop="code" label="权限编码" fixed="left" min-width="250px"></el-table-column>
        <el-table-column prop="name" label="权限名称" fixed="left" min-width="120px"></el-table-column>
        <el-table-column prop="type" label="平台类型" fixed="left" min-width="180px">
          <template slot-scope="{row}">
            <span  v-if="row.isadmin === 1">【平台】</span>
            <span  v-if="row.isshop === 1">【商户】</span>
            <span  v-if="row.iscom === 1">【企业】</span>
          </template>
        </el-table-column>
        <el-table-column prop="remark" label="权限备注" min-width="120px"></el-table-column>
        <el-table-column prop="createUser" label="创建人" min-width="100px">
          <template slot-scope="{row}">{{row.createUserInfo == null ? '' : row.createUserInfo.username}}</template>
        </el-table-column>
        <el-table-column prop="createTime" label="创建时间" min-width="140px" sortable="custom" sort-by="perm.CREATE_TIME"></el-table-column>
        <el-table-column prop="updateUser" label="更新人" min-width="100px">
          <template slot-scope="{row}">{{row.updateUserInfo == null ? '' : row.updateUserInfo.username}}</template>
        </el-table-column>
        <el-table-column prop="updateTime" label="更新时间" min-width="140px"></el-table-column>
        <el-table-column
          v-if="containPermissions(['system:permission:update', 'system:permission:delete'])"
          label="操作"
          min-width="130"
          fixed="right"
        >
          <template slot-scope="{row}">
            <el-button v-if="!row.fixed" type="text" @click="$refs.operaPermissionWindow.open('编辑系统权限', row)" icon="el-icon-edit" v-permissions="['system:permission:update']">编辑</el-button>
            <el-button v-if="!row.fixed" type="text" @click="deleteById(row)" icon="el-icon-delete" v-permissions="['system:permission:delete']">删除</el-button>
          </template>
        </el-table-column>
      </el-table>
      <pagination
        @size-change="handleSizeChange"
        @current-change="handlePageChange"
        :pagination="tableData.pagination"
      ></pagination>
    </template>
    <!-- 新建/修改 -->
    <OperaPermissionWindow ref="operaPermissionWindow" @success="handlePageChange"/>
  </TableLayout>
</template>
 
<script>
import Pagination from '@/components/common/Pagination'
import TableLayout from '@/layouts/TableLayout'
import BaseTable from '@/components/base/BaseTable'
import OperaPermissionWindow from '@/components/system/permission/OperaPermissionWindow'
export default {
  name: 'SystemPermission',
  extends: BaseTable,
  components: { OperaPermissionWindow, TableLayout, Pagination },
  data () {
    return {
      // 搜索
      type: '',
      searchForm: {
        code: '',
        name: '',
        remark: '',
        iscom:null,
        isshop:null,
        isadmin:null
      }
    }
  },
  created () {
    this.config({
      module: '权限',
      api: '/system/permission',
      sorts: [{
        property: 'perm.CREATE_TIME',
        direction: 'DESC'
      }]
    })
    this.search()
  },
  methods:{
    refresh(){
      this.searchForm.iscom = null
      this.searchForm.isshop = null
      this.searchForm.isadmin = null
      if(this.type == 1){
        this.searchForm.iscom = null
        this.searchForm.isshop = null
        this.searchForm.isadmin = 1
      }else if(this.type == 2){
        this.searchForm.iscom = null
        this.searchForm.isshop = 1
        this.searchForm.isadmin = null
      }else if(this.type == 2){
        this.searchForm.iscom = 1
        this.searchForm.isshop = null
        this.searchForm.isadmin = null
      }
      this.search()
    }
  }
 
}
</script>